<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<title>Source code</title>
<link rel="stylesheet" type="text/css" href="../../../../../stylesheet.css" title="Style">
</head>
<body>
<div class="sourceContainer">
<pre><span class="sourceLineNo">001</span>/*<a name="line.1"></a>
<span class="sourceLineNo">002</span> * Licensed to the Apache Software Foundation (ASF) under one or more<a name="line.2"></a>
<span class="sourceLineNo">003</span> * contributor license agreements.  See the NOTICE file distributed with<a name="line.3"></a>
<span class="sourceLineNo">004</span> * this work for additional information regarding copyright ownership.<a name="line.4"></a>
<span class="sourceLineNo">005</span> * The ASF licenses this file to You under the Apache License, Version 2.0<a name="line.5"></a>
<span class="sourceLineNo">006</span> * (the "License"); you may not use this file except in compliance with<a name="line.6"></a>
<span class="sourceLineNo">007</span> * the License.  You may obtain a copy of the License at<a name="line.7"></a>
<span class="sourceLineNo">008</span> *<a name="line.8"></a>
<span class="sourceLineNo">009</span> *      http://www.apache.org/licenses/LICENSE-2.0<a name="line.9"></a>
<span class="sourceLineNo">010</span> *<a name="line.10"></a>
<span class="sourceLineNo">011</span> * Unless required by applicable law or agreed to in writing, software<a name="line.11"></a>
<span class="sourceLineNo">012</span> * distributed under the License is distributed on an "AS IS" BASIS,<a name="line.12"></a>
<span class="sourceLineNo">013</span> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<a name="line.13"></a>
<span class="sourceLineNo">014</span> * See the License for the specific language governing permissions and<a name="line.14"></a>
<span class="sourceLineNo">015</span> * limitations under the License.<a name="line.15"></a>
<span class="sourceLineNo">016</span> */<a name="line.16"></a>
<span class="sourceLineNo">017</span>package org.apache.commons.dbcp2;<a name="line.17"></a>
<span class="sourceLineNo">018</span><a name="line.18"></a>
<span class="sourceLineNo">019</span>import java.io.OutputStreamWriter;<a name="line.19"></a>
<span class="sourceLineNo">020</span>import java.io.PrintWriter;<a name="line.20"></a>
<span class="sourceLineNo">021</span>import java.nio.charset.StandardCharsets;<a name="line.21"></a>
<span class="sourceLineNo">022</span>import java.security.AccessController;<a name="line.22"></a>
<span class="sourceLineNo">023</span>import java.security.PrivilegedActionException;<a name="line.23"></a>
<span class="sourceLineNo">024</span>import java.security.PrivilegedExceptionAction;<a name="line.24"></a>
<span class="sourceLineNo">025</span>import java.sql.Connection;<a name="line.25"></a>
<span class="sourceLineNo">026</span>import java.sql.Driver;<a name="line.26"></a>
<span class="sourceLineNo">027</span>import java.sql.DriverManager;<a name="line.27"></a>
<span class="sourceLineNo">028</span>import java.sql.SQLException;<a name="line.28"></a>
<span class="sourceLineNo">029</span>import java.sql.SQLFeatureNotSupportedException;<a name="line.29"></a>
<span class="sourceLineNo">030</span>import java.util.ArrayList;<a name="line.30"></a>
<span class="sourceLineNo">031</span>import java.util.Collection;<a name="line.31"></a>
<span class="sourceLineNo">032</span>import java.util.Collections;<a name="line.32"></a>
<span class="sourceLineNo">033</span>import java.util.HashSet;<a name="line.33"></a>
<span class="sourceLineNo">034</span>import java.util.List;<a name="line.34"></a>
<span class="sourceLineNo">035</span>import java.util.Objects;<a name="line.35"></a>
<span class="sourceLineNo">036</span>import java.util.Properties;<a name="line.36"></a>
<span class="sourceLineNo">037</span>import java.util.Set;<a name="line.37"></a>
<span class="sourceLineNo">038</span>import java.util.logging.Logger;<a name="line.38"></a>
<span class="sourceLineNo">039</span><a name="line.39"></a>
<span class="sourceLineNo">040</span>import javax.management.MBeanRegistration;<a name="line.40"></a>
<span class="sourceLineNo">041</span>import javax.management.MBeanServer;<a name="line.41"></a>
<span class="sourceLineNo">042</span>import javax.management.MalformedObjectNameException;<a name="line.42"></a>
<span class="sourceLineNo">043</span>import javax.management.NotCompliantMBeanException;<a name="line.43"></a>
<span class="sourceLineNo">044</span>import javax.management.ObjectName;<a name="line.44"></a>
<span class="sourceLineNo">045</span>import javax.management.StandardMBean;<a name="line.45"></a>
<span class="sourceLineNo">046</span>import javax.sql.DataSource;<a name="line.46"></a>
<span class="sourceLineNo">047</span><a name="line.47"></a>
<span class="sourceLineNo">048</span>import org.apache.commons.logging.Log;<a name="line.48"></a>
<span class="sourceLineNo">049</span>import org.apache.commons.logging.LogFactory;<a name="line.49"></a>
<span class="sourceLineNo">050</span>import org.apache.commons.pool2.PooledObject;<a name="line.50"></a>
<span class="sourceLineNo">051</span>import org.apache.commons.pool2.impl.AbandonedConfig;<a name="line.51"></a>
<span class="sourceLineNo">052</span>import org.apache.commons.pool2.impl.BaseObjectPoolConfig;<a name="line.52"></a>
<span class="sourceLineNo">053</span>import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig;<a name="line.53"></a>
<span class="sourceLineNo">054</span>import org.apache.commons.pool2.impl.GenericObjectPool;<a name="line.54"></a>
<span class="sourceLineNo">055</span>import org.apache.commons.pool2.impl.GenericObjectPoolConfig;<a name="line.55"></a>
<span class="sourceLineNo">056</span><a name="line.56"></a>
<span class="sourceLineNo">057</span>/**<a name="line.57"></a>
<span class="sourceLineNo">058</span> * Basic implementation of &lt;code&gt;javax.sql.DataSource&lt;/code&gt; that is configured via JavaBeans properties.<a name="line.58"></a>
<span class="sourceLineNo">059</span> *<a name="line.59"></a>
<span class="sourceLineNo">060</span> * &lt;p&gt;<a name="line.60"></a>
<span class="sourceLineNo">061</span> * This is not the only way to combine the &lt;em&gt;commons-dbcp2&lt;/em&gt; and &lt;em&gt;commons-pool2&lt;/em&gt; packages, but provides a<a name="line.61"></a>
<span class="sourceLineNo">062</span> * one-stop solution for basic requirements.<a name="line.62"></a>
<span class="sourceLineNo">063</span> * &lt;/p&gt;<a name="line.63"></a>
<span class="sourceLineNo">064</span> *<a name="line.64"></a>
<span class="sourceLineNo">065</span> * @since 2.0<a name="line.65"></a>
<span class="sourceLineNo">066</span> */<a name="line.66"></a>
<span class="sourceLineNo">067</span>public class BasicDataSource implements DataSource, BasicDataSourceMXBean, MBeanRegistration, AutoCloseable {<a name="line.67"></a>
<span class="sourceLineNo">068</span><a name="line.68"></a>
<span class="sourceLineNo">069</span>    private static final Log log = LogFactory.getLog(BasicDataSource.class);<a name="line.69"></a>
<span class="sourceLineNo">070</span><a name="line.70"></a>
<span class="sourceLineNo">071</span>    static {<a name="line.71"></a>
<span class="sourceLineNo">072</span>        // Attempt to prevent deadlocks - see DBCP - 272<a name="line.72"></a>
<span class="sourceLineNo">073</span>        DriverManager.getDrivers();<a name="line.73"></a>
<span class="sourceLineNo">074</span>        try {<a name="line.74"></a>
<span class="sourceLineNo">075</span>            // Load classes now to prevent AccessControlExceptions later<a name="line.75"></a>
<span class="sourceLineNo">076</span>            // A number of classes are loaded when getConnection() is called<a name="line.76"></a>
<span class="sourceLineNo">077</span>            // but the following classes are not loaded and therefore require<a name="line.77"></a>
<span class="sourceLineNo">078</span>            // explicit loading.<a name="line.78"></a>
<span class="sourceLineNo">079</span>            if (Utils.isSecurityEnabled()) {<a name="line.79"></a>
<span class="sourceLineNo">080</span>                final ClassLoader loader = BasicDataSource.class.getClassLoader();<a name="line.80"></a>
<span class="sourceLineNo">081</span>                final String dbcpPackageName = BasicDataSource.class.getPackage().getName();<a name="line.81"></a>
<span class="sourceLineNo">082</span>                loader.loadClass(dbcpPackageName + ".DelegatingCallableStatement");<a name="line.82"></a>
<span class="sourceLineNo">083</span>                loader.loadClass(dbcpPackageName + ".DelegatingDatabaseMetaData");<a name="line.83"></a>
<span class="sourceLineNo">084</span>                loader.loadClass(dbcpPackageName + ".DelegatingPreparedStatement");<a name="line.84"></a>
<span class="sourceLineNo">085</span>                loader.loadClass(dbcpPackageName + ".DelegatingResultSet");<a name="line.85"></a>
<span class="sourceLineNo">086</span>                loader.loadClass(dbcpPackageName + ".PoolableCallableStatement");<a name="line.86"></a>
<span class="sourceLineNo">087</span>                loader.loadClass(dbcpPackageName + ".PoolablePreparedStatement");<a name="line.87"></a>
<span class="sourceLineNo">088</span>                loader.loadClass(dbcpPackageName + ".PoolingConnection$StatementType");<a name="line.88"></a>
<span class="sourceLineNo">089</span>                loader.loadClass(dbcpPackageName + ".PStmtKey");<a name="line.89"></a>
<span class="sourceLineNo">090</span><a name="line.90"></a>
<span class="sourceLineNo">091</span>                final String poolPackageName = PooledObject.class.getPackage().getName();<a name="line.91"></a>
<span class="sourceLineNo">092</span>                loader.loadClass(poolPackageName + ".impl.LinkedBlockingDeque$Node");<a name="line.92"></a>
<span class="sourceLineNo">093</span>                loader.loadClass(poolPackageName + ".impl.GenericKeyedObjectPool$ObjectDeque");<a name="line.93"></a>
<span class="sourceLineNo">094</span>            }<a name="line.94"></a>
<span class="sourceLineNo">095</span>        } catch (final ClassNotFoundException cnfe) {<a name="line.95"></a>
<span class="sourceLineNo">096</span>            throw new IllegalStateException("Unable to pre-load classes", cnfe);<a name="line.96"></a>
<span class="sourceLineNo">097</span>        }<a name="line.97"></a>
<span class="sourceLineNo">098</span>    }<a name="line.98"></a>
<span class="sourceLineNo">099</span><a name="line.99"></a>
<span class="sourceLineNo">100</span>    @SuppressWarnings("resource")<a name="line.100"></a>
<span class="sourceLineNo">101</span>    protected static void validateConnectionFactory(final PoolableConnectionFactory connectionFactory)<a name="line.101"></a>
<span class="sourceLineNo">102</span>            throws Exception {<a name="line.102"></a>
<span class="sourceLineNo">103</span>        PoolableConnection conn = null;<a name="line.103"></a>
<span class="sourceLineNo">104</span>        PooledObject&lt;PoolableConnection&gt; p = null;<a name="line.104"></a>
<span class="sourceLineNo">105</span>        try {<a name="line.105"></a>
<span class="sourceLineNo">106</span>            p = connectionFactory.makeObject();<a name="line.106"></a>
<span class="sourceLineNo">107</span>            conn = p.getObject();<a name="line.107"></a>
<span class="sourceLineNo">108</span>            connectionFactory.activateObject(p);<a name="line.108"></a>
<span class="sourceLineNo">109</span>            connectionFactory.validateConnection(conn);<a name="line.109"></a>
<span class="sourceLineNo">110</span>            connectionFactory.passivateObject(p);<a name="line.110"></a>
<span class="sourceLineNo">111</span>        } finally {<a name="line.111"></a>
<span class="sourceLineNo">112</span>            if (p != null) {<a name="line.112"></a>
<span class="sourceLineNo">113</span>                connectionFactory.destroyObject(p);<a name="line.113"></a>
<span class="sourceLineNo">114</span>            }<a name="line.114"></a>
<span class="sourceLineNo">115</span>        }<a name="line.115"></a>
<span class="sourceLineNo">116</span>    }<a name="line.116"></a>
<span class="sourceLineNo">117</span><a name="line.117"></a>
<span class="sourceLineNo">118</span>    /**<a name="line.118"></a>
<span class="sourceLineNo">119</span>     * The default auto-commit state of connections created by this pool.<a name="line.119"></a>
<span class="sourceLineNo">120</span>     */<a name="line.120"></a>
<span class="sourceLineNo">121</span>    private volatile Boolean defaultAutoCommit;<a name="line.121"></a>
<span class="sourceLineNo">122</span><a name="line.122"></a>
<span class="sourceLineNo">123</span>    /**<a name="line.123"></a>
<span class="sourceLineNo">124</span>     * The default read-only state of connections created by this pool.<a name="line.124"></a>
<span class="sourceLineNo">125</span>     */<a name="line.125"></a>
<span class="sourceLineNo">126</span>    private transient Boolean defaultReadOnly;<a name="line.126"></a>
<span class="sourceLineNo">127</span><a name="line.127"></a>
<span class="sourceLineNo">128</span>    /**<a name="line.128"></a>
<span class="sourceLineNo">129</span>     * The default TransactionIsolation state of connections created by this pool.<a name="line.129"></a>
<span class="sourceLineNo">130</span>     */<a name="line.130"></a>
<span class="sourceLineNo">131</span>    private volatile int defaultTransactionIsolation = PoolableConnectionFactory.UNKNOWN_TRANSACTION_ISOLATION;<a name="line.131"></a>
<span class="sourceLineNo">132</span><a name="line.132"></a>
<span class="sourceLineNo">133</span>    private Integer defaultQueryTimeoutSeconds;<a name="line.133"></a>
<span class="sourceLineNo">134</span><a name="line.134"></a>
<span class="sourceLineNo">135</span>    /**<a name="line.135"></a>
<span class="sourceLineNo">136</span>     * The default "catalog" of connections created by this pool.<a name="line.136"></a>
<span class="sourceLineNo">137</span>     */<a name="line.137"></a>
<span class="sourceLineNo">138</span>    private volatile String defaultCatalog;<a name="line.138"></a>
<span class="sourceLineNo">139</span><a name="line.139"></a>
<span class="sourceLineNo">140</span>    /**<a name="line.140"></a>
<span class="sourceLineNo">141</span>     * The default "schema" of connections created by this pool.<a name="line.141"></a>
<span class="sourceLineNo">142</span>     */<a name="line.142"></a>
<span class="sourceLineNo">143</span>    private volatile String defaultSchema;<a name="line.143"></a>
<span class="sourceLineNo">144</span><a name="line.144"></a>
<span class="sourceLineNo">145</span>    /**<a name="line.145"></a>
<span class="sourceLineNo">146</span>     * The property that controls if the pooled connections cache some state rather than query the database for current<a name="line.146"></a>
<span class="sourceLineNo">147</span>     * state to improve performance.<a name="line.147"></a>
<span class="sourceLineNo">148</span>     */<a name="line.148"></a>
<span class="sourceLineNo">149</span>    private boolean cacheState = true;<a name="line.149"></a>
<span class="sourceLineNo">150</span><a name="line.150"></a>
<span class="sourceLineNo">151</span>    /**<a name="line.151"></a>
<span class="sourceLineNo">152</span>     * The instance of the JDBC Driver to use.<a name="line.152"></a>
<span class="sourceLineNo">153</span>     */<a name="line.153"></a>
<span class="sourceLineNo">154</span>    private Driver driver;<a name="line.154"></a>
<span class="sourceLineNo">155</span><a name="line.155"></a>
<span class="sourceLineNo">156</span>    /**<a name="line.156"></a>
<span class="sourceLineNo">157</span>     * The fully qualified Java class name of the JDBC driver to be used.<a name="line.157"></a>
<span class="sourceLineNo">158</span>     */<a name="line.158"></a>
<span class="sourceLineNo">159</span>    private String driverClassName;<a name="line.159"></a>
<span class="sourceLineNo">160</span><a name="line.160"></a>
<span class="sourceLineNo">161</span>    /**<a name="line.161"></a>
<span class="sourceLineNo">162</span>     * The class loader instance to use to load the JDBC driver. If not specified, {@link Class#forName(String)} is used<a name="line.162"></a>
<span class="sourceLineNo">163</span>     * to load the JDBC driver. If specified, {@link Class#forName(String, boolean, ClassLoader)} is used.<a name="line.163"></a>
<span class="sourceLineNo">164</span>     */<a name="line.164"></a>
<span class="sourceLineNo">165</span>    private ClassLoader driverClassLoader;<a name="line.165"></a>
<span class="sourceLineNo">166</span><a name="line.166"></a>
<span class="sourceLineNo">167</span>    /**<a name="line.167"></a>
<span class="sourceLineNo">168</span>     * True means that borrowObject returns the most recently used ("last in") connection in the pool (if there are idle<a name="line.168"></a>
<span class="sourceLineNo">169</span>     * connections available). False means that the pool behaves as a FIFO queue - connections are taken from the idle<a name="line.169"></a>
<span class="sourceLineNo">170</span>     * instance pool in the order that they are returned to the pool.<a name="line.170"></a>
<span class="sourceLineNo">171</span>     */<a name="line.171"></a>
<span class="sourceLineNo">172</span>    private boolean lifo = BaseObjectPoolConfig.DEFAULT_LIFO;<a name="line.172"></a>
<span class="sourceLineNo">173</span><a name="line.173"></a>
<span class="sourceLineNo">174</span>    /**<a name="line.174"></a>
<span class="sourceLineNo">175</span>     * The maximum number of active connections that can be allocated from this pool at the same time, or negative for<a name="line.175"></a>
<span class="sourceLineNo">176</span>     * no limit.<a name="line.176"></a>
<span class="sourceLineNo">177</span>     */<a name="line.177"></a>
<span class="sourceLineNo">178</span>    private int maxTotal = GenericObjectPoolConfig.DEFAULT_MAX_TOTAL;<a name="line.178"></a>
<span class="sourceLineNo">179</span><a name="line.179"></a>
<span class="sourceLineNo">180</span>    /**<a name="line.180"></a>
<span class="sourceLineNo">181</span>     * The maximum number of connections that can remain idle in the pool, without extra ones being destroyed, or<a name="line.181"></a>
<span class="sourceLineNo">182</span>     * negative for no limit. If maxIdle is set too low on heavily loaded systems it is possible you will see<a name="line.182"></a>
<span class="sourceLineNo">183</span>     * connections being closed and almost immediately new connections being opened. This is a result of the active<a name="line.183"></a>
<span class="sourceLineNo">184</span>     * threads momentarily closing connections faster than they are opening them, causing the number of idle connections<a name="line.184"></a>
<span class="sourceLineNo">185</span>     * to rise above maxIdle. The best value for maxIdle for heavily loaded system will vary but the default is a good<a name="line.185"></a>
<span class="sourceLineNo">186</span>     * starting point.<a name="line.186"></a>
<span class="sourceLineNo">187</span>     */<a name="line.187"></a>
<span class="sourceLineNo">188</span>    private int maxIdle = GenericObjectPoolConfig.DEFAULT_MAX_IDLE;<a name="line.188"></a>
<span class="sourceLineNo">189</span><a name="line.189"></a>
<span class="sourceLineNo">190</span>    /**<a name="line.190"></a>
<span class="sourceLineNo">191</span>     * The minimum number of active connections that can remain idle in the pool, without extra ones being created when<a name="line.191"></a>
<span class="sourceLineNo">192</span>     * the evictor runs, or 0 to create none. The pool attempts to ensure that minIdle connections are available when<a name="line.192"></a>
<span class="sourceLineNo">193</span>     * the idle object evictor runs. The value of this property has no effect unless<a name="line.193"></a>
<span class="sourceLineNo">194</span>     * {@link #timeBetweenEvictionRunsMillis} has a positive value.<a name="line.194"></a>
<span class="sourceLineNo">195</span>     */<a name="line.195"></a>
<span class="sourceLineNo">196</span>    private int minIdle = GenericObjectPoolConfig.DEFAULT_MIN_IDLE;<a name="line.196"></a>
<span class="sourceLineNo">197</span><a name="line.197"></a>
<span class="sourceLineNo">198</span>    /**<a name="line.198"></a>
<span class="sourceLineNo">199</span>     * The initial number of connections that are created when the pool is started.<a name="line.199"></a>
<span class="sourceLineNo">200</span>     */<a name="line.200"></a>
<span class="sourceLineNo">201</span>    private int initialSize;<a name="line.201"></a>
<span class="sourceLineNo">202</span><a name="line.202"></a>
<span class="sourceLineNo">203</span>    /**<a name="line.203"></a>
<span class="sourceLineNo">204</span>     * The maximum number of milliseconds that the pool will wait (when there are no available connections) for a<a name="line.204"></a>
<span class="sourceLineNo">205</span>     * connection to be returned before throwing an exception, or &lt;= 0 to wait indefinitely.<a name="line.205"></a>
<span class="sourceLineNo">206</span>     */<a name="line.206"></a>
<span class="sourceLineNo">207</span>    private long maxWaitMillis = BaseObjectPoolConfig.DEFAULT_MAX_WAIT_MILLIS;<a name="line.207"></a>
<span class="sourceLineNo">208</span><a name="line.208"></a>
<span class="sourceLineNo">209</span>    /**<a name="line.209"></a>
<span class="sourceLineNo">210</span>     * Prepared statement pooling for this pool. When this property is set to &lt;code&gt;true&lt;/code&gt; both PreparedStatements<a name="line.210"></a>
<span class="sourceLineNo">211</span>     * and CallableStatements are pooled.<a name="line.211"></a>
<span class="sourceLineNo">212</span>     */<a name="line.212"></a>
<span class="sourceLineNo">213</span>    private boolean poolPreparedStatements;<a name="line.213"></a>
<span class="sourceLineNo">214</span><a name="line.214"></a>
<span class="sourceLineNo">215</span>    private boolean clearStatementPoolOnReturn;<a name="line.215"></a>
<span class="sourceLineNo">216</span><a name="line.216"></a>
<span class="sourceLineNo">217</span>    /**<a name="line.217"></a>
<span class="sourceLineNo">218</span>     * &lt;p&gt;<a name="line.218"></a>
<span class="sourceLineNo">219</span>     * The maximum number of open statements that can be allocated from the statement pool at the same time, or negative<a name="line.219"></a>
<span class="sourceLineNo">220</span>     * for no limit. Since a connection usually only uses one or two statements at a time, this is mostly used to help<a name="line.220"></a>
<span class="sourceLineNo">221</span>     * detect resource leaks.<a name="line.221"></a>
<span class="sourceLineNo">222</span>     * &lt;/p&gt;<a name="line.222"></a>
<span class="sourceLineNo">223</span>     * &lt;p&gt;<a name="line.223"></a>
<span class="sourceLineNo">224</span>     * Note: As of version 1.3, CallableStatements (those produced by {@link Connection#prepareCall}) are pooled along<a name="line.224"></a>
<span class="sourceLineNo">225</span>     * with PreparedStatements (produced by {@link Connection#prepareStatement}) and<a name="line.225"></a>
<span class="sourceLineNo">226</span>     * &lt;code&gt;maxOpenPreparedStatements&lt;/code&gt; limits the total number of prepared or callable statements that may be in<a name="line.226"></a>
<span class="sourceLineNo">227</span>     * use at a given time.<a name="line.227"></a>
<span class="sourceLineNo">228</span>     * &lt;/p&gt;<a name="line.228"></a>
<span class="sourceLineNo">229</span>     */<a name="line.229"></a>
<span class="sourceLineNo">230</span>    private int maxOpenPreparedStatements = GenericKeyedObjectPoolConfig.DEFAULT_MAX_TOTAL;<a name="line.230"></a>
<span class="sourceLineNo">231</span><a name="line.231"></a>
<span class="sourceLineNo">232</span>    /**<a name="line.232"></a>
<span class="sourceLineNo">233</span>     * The indication of whether objects will be validated as soon as they have been created by the pool. If the object<a name="line.233"></a>
<span class="sourceLineNo">234</span>     * fails to validate, the borrow operation that triggered the creation will fail.<a name="line.234"></a>
<span class="sourceLineNo">235</span>     */<a name="line.235"></a>
<span class="sourceLineNo">236</span>    private boolean testOnCreate;<a name="line.236"></a>
<span class="sourceLineNo">237</span><a name="line.237"></a>
<span class="sourceLineNo">238</span>    /**<a name="line.238"></a>
<span class="sourceLineNo">239</span>     * The indication of whether objects will be validated before being borrowed from the pool. If the object fails to<a name="line.239"></a>
<span class="sourceLineNo">240</span>     * validate, it will be dropped from the pool, and we will attempt to borrow another.<a name="line.240"></a>
<span class="sourceLineNo">241</span>     */<a name="line.241"></a>
<span class="sourceLineNo">242</span>    private boolean testOnBorrow = true;<a name="line.242"></a>
<span class="sourceLineNo">243</span><a name="line.243"></a>
<span class="sourceLineNo">244</span>    /**<a name="line.244"></a>
<span class="sourceLineNo">245</span>     * The indication of whether objects will be validated before being returned to the pool.<a name="line.245"></a>
<span class="sourceLineNo">246</span>     */<a name="line.246"></a>
<span class="sourceLineNo">247</span>    private boolean testOnReturn;<a name="line.247"></a>
<span class="sourceLineNo">248</span><a name="line.248"></a>
<span class="sourceLineNo">249</span>    /**<a name="line.249"></a>
<span class="sourceLineNo">250</span>     * The number of milliseconds to sleep between runs of the idle object evictor thread. When non-positive, no idle<a name="line.250"></a>
<span class="sourceLineNo">251</span>     * object evictor thread will be run.<a name="line.251"></a>
<span class="sourceLineNo">252</span>     */<a name="line.252"></a>
<span class="sourceLineNo">253</span>    private long timeBetweenEvictionRunsMillis = BaseObjectPoolConfig.DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS;<a name="line.253"></a>
<span class="sourceLineNo">254</span><a name="line.254"></a>
<span class="sourceLineNo">255</span>    /**<a name="line.255"></a>
<span class="sourceLineNo">256</span>     * The number of objects to examine during each run of the idle object evictor thread (if any).<a name="line.256"></a>
<span class="sourceLineNo">257</span>     */<a name="line.257"></a>
<span class="sourceLineNo">258</span>    private int numTestsPerEvictionRun = BaseObjectPoolConfig.DEFAULT_NUM_TESTS_PER_EVICTION_RUN;<a name="line.258"></a>
<span class="sourceLineNo">259</span><a name="line.259"></a>
<span class="sourceLineNo">260</span>    /**<a name="line.260"></a>
<span class="sourceLineNo">261</span>     * The minimum amount of time an object may sit idle in the pool before it is eligible for eviction by the idle<a name="line.261"></a>
<span class="sourceLineNo">262</span>     * object evictor (if any).<a name="line.262"></a>
<span class="sourceLineNo">263</span>     */<a name="line.263"></a>
<span class="sourceLineNo">264</span>    private long minEvictableIdleTimeMillis = BaseObjectPoolConfig.DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS;<a name="line.264"></a>
<span class="sourceLineNo">265</span><a name="line.265"></a>
<span class="sourceLineNo">266</span>    /**<a name="line.266"></a>
<span class="sourceLineNo">267</span>     * The minimum amount of time a connection may sit idle in the pool before it is eligible for eviction by the idle<a name="line.267"></a>
<span class="sourceLineNo">268</span>     * object evictor, with the extra condition that at least "minIdle" connections remain in the pool. Note that<a name="line.268"></a>
<span class="sourceLineNo">269</span>     * {@code minEvictableIdleTimeMillis} takes precedence over this parameter. See<a name="line.269"></a>
<span class="sourceLineNo">270</span>     * {@link #getSoftMinEvictableIdleTimeMillis()}.<a name="line.270"></a>
<span class="sourceLineNo">271</span>     */<a name="line.271"></a>
<span class="sourceLineNo">272</span>    private long softMinEvictableIdleTimeMillis = BaseObjectPoolConfig.DEFAULT_SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS;<a name="line.272"></a>
<span class="sourceLineNo">273</span><a name="line.273"></a>
<span class="sourceLineNo">274</span>    private String evictionPolicyClassName = BaseObjectPoolConfig.DEFAULT_EVICTION_POLICY_CLASS_NAME;<a name="line.274"></a>
<span class="sourceLineNo">275</span><a name="line.275"></a>
<span class="sourceLineNo">276</span>    /**<a name="line.276"></a>
<span class="sourceLineNo">277</span>     * The indication of whether objects will be validated by the idle object evictor (if any). If an object fails to<a name="line.277"></a>
<span class="sourceLineNo">278</span>     * validate, it will be dropped from the pool.<a name="line.278"></a>
<span class="sourceLineNo">279</span>     */<a name="line.279"></a>
<span class="sourceLineNo">280</span>    private boolean testWhileIdle;<a name="line.280"></a>
<span class="sourceLineNo">281</span><a name="line.281"></a>
<span class="sourceLineNo">282</span>    /**<a name="line.282"></a>
<span class="sourceLineNo">283</span>     * The connection password to be passed to our JDBC driver to establish a connection.<a name="line.283"></a>
<span class="sourceLineNo">284</span>     */<a name="line.284"></a>
<span class="sourceLineNo">285</span>    private volatile String password;<a name="line.285"></a>
<span class="sourceLineNo">286</span><a name="line.286"></a>
<span class="sourceLineNo">287</span>    /**<a name="line.287"></a>
<span class="sourceLineNo">288</span>     * The connection URL to be passed to our JDBC driver to establish a connection.<a name="line.288"></a>
<span class="sourceLineNo">289</span>     */<a name="line.289"></a>
<span class="sourceLineNo">290</span>    private String url;<a name="line.290"></a>
<span class="sourceLineNo">291</span><a name="line.291"></a>
<span class="sourceLineNo">292</span>    /**<a name="line.292"></a>
<span class="sourceLineNo">293</span>     * The connection user name to be passed to our JDBC driver to establish a connection.<a name="line.293"></a>
<span class="sourceLineNo">294</span>     */<a name="line.294"></a>
<span class="sourceLineNo">295</span>    private String userName;<a name="line.295"></a>
<span class="sourceLineNo">296</span><a name="line.296"></a>
<span class="sourceLineNo">297</span>    /**<a name="line.297"></a>
<span class="sourceLineNo">298</span>     * The SQL query that will be used to validate connections from this pool before returning them to the caller. If<a name="line.298"></a>
<span class="sourceLineNo">299</span>     * specified, this query &lt;strong&gt;MUST&lt;/strong&gt; be an SQL SELECT statement that returns at least one row. If not<a name="line.299"></a>
<span class="sourceLineNo">300</span>     * specified, {@link Connection#isValid(int)} will be used to validate connections.<a name="line.300"></a>
<span class="sourceLineNo">301</span>     */<a name="line.301"></a>
<span class="sourceLineNo">302</span>    private volatile String validationQuery;<a name="line.302"></a>
<span class="sourceLineNo">303</span><a name="line.303"></a>
<span class="sourceLineNo">304</span>    /**<a name="line.304"></a>
<span class="sourceLineNo">305</span>     * Timeout in seconds before connection validation queries fail.<a name="line.305"></a>
<span class="sourceLineNo">306</span>     */<a name="line.306"></a>
<span class="sourceLineNo">307</span>    private volatile int validationQueryTimeoutSeconds = -1;<a name="line.307"></a>
<span class="sourceLineNo">308</span><a name="line.308"></a>
<span class="sourceLineNo">309</span>    /**<a name="line.309"></a>
<span class="sourceLineNo">310</span>     * The fully qualified Java class name of a {@link ConnectionFactory} implementation.<a name="line.310"></a>
<span class="sourceLineNo">311</span>     */<a name="line.311"></a>
<span class="sourceLineNo">312</span>    private String connectionFactoryClassName;<a name="line.312"></a>
<span class="sourceLineNo">313</span><a name="line.313"></a>
<span class="sourceLineNo">314</span>    /**<a name="line.314"></a>
<span class="sourceLineNo">315</span>     * These SQL statements run once after a Connection is created.<a name="line.315"></a>
<span class="sourceLineNo">316</span>     * &lt;p&gt;<a name="line.316"></a>
<span class="sourceLineNo">317</span>     * This property can be used for example to run ALTER SESSION SET NLS_SORT=XCYECH in an Oracle Database only once<a name="line.317"></a>
<span class="sourceLineNo">318</span>     * after connection creation.<a name="line.318"></a>
<span class="sourceLineNo">319</span>     * &lt;/p&gt;<a name="line.319"></a>
<span class="sourceLineNo">320</span>     */<a name="line.320"></a>
<span class="sourceLineNo">321</span>    private volatile List&lt;String&gt; connectionInitSqls;<a name="line.321"></a>
<span class="sourceLineNo">322</span><a name="line.322"></a>
<span class="sourceLineNo">323</span>    /**<a name="line.323"></a>
<span class="sourceLineNo">324</span>     * Controls access to the underlying connection.<a name="line.324"></a>
<span class="sourceLineNo">325</span>     */<a name="line.325"></a>
<span class="sourceLineNo">326</span>    private boolean accessToUnderlyingConnectionAllowed;<a name="line.326"></a>
<span class="sourceLineNo">327</span><a name="line.327"></a>
<span class="sourceLineNo">328</span>    private long maxConnLifetimeMillis = -1;<a name="line.328"></a>
<span class="sourceLineNo">329</span><a name="line.329"></a>
<span class="sourceLineNo">330</span>    private boolean logExpiredConnections = true;<a name="line.330"></a>
<span class="sourceLineNo">331</span><a name="line.331"></a>
<span class="sourceLineNo">332</span>    private String jmxName;<a name="line.332"></a>
<span class="sourceLineNo">333</span><a name="line.333"></a>
<span class="sourceLineNo">334</span>    private boolean autoCommitOnReturn = true;<a name="line.334"></a>
<span class="sourceLineNo">335</span><a name="line.335"></a>
<span class="sourceLineNo">336</span>    private boolean rollbackOnReturn = true;<a name="line.336"></a>
<span class="sourceLineNo">337</span><a name="line.337"></a>
<span class="sourceLineNo">338</span>    private volatile Set&lt;String&gt; disconnectionSqlCodes;<a name="line.338"></a>
<span class="sourceLineNo">339</span><a name="line.339"></a>
<span class="sourceLineNo">340</span>    private boolean fastFailValidation;<a name="line.340"></a>
<span class="sourceLineNo">341</span><a name="line.341"></a>
<span class="sourceLineNo">342</span>    /**<a name="line.342"></a>
<span class="sourceLineNo">343</span>     * The object pool that internally manages our connections.<a name="line.343"></a>
<span class="sourceLineNo">344</span>     */<a name="line.344"></a>
<span class="sourceLineNo">345</span>    private volatile GenericObjectPool&lt;PoolableConnection&gt; connectionPool;<a name="line.345"></a>
<span class="sourceLineNo">346</span><a name="line.346"></a>
<span class="sourceLineNo">347</span>    /**<a name="line.347"></a>
<span class="sourceLineNo">348</span>     * The connection properties that will be sent to our JDBC driver when establishing new connections.<a name="line.348"></a>
<span class="sourceLineNo">349</span>     * &lt;strong&gt;NOTE&lt;/strong&gt; - The "user" and "password" properties will be passed explicitly, so they do not need to be<a name="line.349"></a>
<span class="sourceLineNo">350</span>     * included here.<a name="line.350"></a>
<span class="sourceLineNo">351</span>     */<a name="line.351"></a>
<span class="sourceLineNo">352</span>    private Properties connectionProperties = new Properties();<a name="line.352"></a>
<span class="sourceLineNo">353</span><a name="line.353"></a>
<span class="sourceLineNo">354</span>    /**<a name="line.354"></a>
<span class="sourceLineNo">355</span>     * The data source we will use to manage connections. This object should be acquired &lt;strong&gt;ONLY&lt;/strong&gt; by calls<a name="line.355"></a>
<span class="sourceLineNo">356</span>     * to the &lt;code&gt;createDataSource()&lt;/code&gt; method.<a name="line.356"></a>
<span class="sourceLineNo">357</span>     */<a name="line.357"></a>
<span class="sourceLineNo">358</span>    private volatile DataSource dataSource;<a name="line.358"></a>
<span class="sourceLineNo">359</span><a name="line.359"></a>
<span class="sourceLineNo">360</span>    /**<a name="line.360"></a>
<span class="sourceLineNo">361</span>     * The PrintWriter to which log messages should be directed.<a name="line.361"></a>
<span class="sourceLineNo">362</span>     */<a name="line.362"></a>
<span class="sourceLineNo">363</span>    private volatile PrintWriter logWriter = new PrintWriter(<a name="line.363"></a>
<span class="sourceLineNo">364</span>            new OutputStreamWriter(System.out, StandardCharsets.UTF_8));<a name="line.364"></a>
<span class="sourceLineNo">365</span><a name="line.365"></a>
<span class="sourceLineNo">366</span>    private AbandonedConfig abandonedConfig;<a name="line.366"></a>
<span class="sourceLineNo">367</span><a name="line.367"></a>
<span class="sourceLineNo">368</span>    private boolean closed;<a name="line.368"></a>
<span class="sourceLineNo">369</span><a name="line.369"></a>
<span class="sourceLineNo">370</span>    /**<a name="line.370"></a>
<span class="sourceLineNo">371</span>     * Actual name under which this component has been registered.<a name="line.371"></a>
<span class="sourceLineNo">372</span>     */<a name="line.372"></a>
<span class="sourceLineNo">373</span>    private ObjectNameWrapper registeredJmxObjectName;<a name="line.373"></a>
<span class="sourceLineNo">374</span><a name="line.374"></a>
<span class="sourceLineNo">375</span>    /**<a name="line.375"></a>
<span class="sourceLineNo">376</span>     * Adds a custom connection property to the set that will be passed to our JDBC driver. This &lt;strong&gt;MUST&lt;/strong&gt;<a name="line.376"></a>
<span class="sourceLineNo">377</span>     * be called before the first connection is retrieved (along with all the other configuration property setters).<a name="line.377"></a>
<span class="sourceLineNo">378</span>     * Calls to this method after the connection pool has been initialized have no effect.<a name="line.378"></a>
<span class="sourceLineNo">379</span>     *<a name="line.379"></a>
<span class="sourceLineNo">380</span>     * @param name  Name of the custom connection property<a name="line.380"></a>
<span class="sourceLineNo">381</span>     * @param value Value of the custom connection property<a name="line.381"></a>
<span class="sourceLineNo">382</span>     */<a name="line.382"></a>
<span class="sourceLineNo">383</span>    public void addConnectionProperty(final String name, final String value) {<a name="line.383"></a>
<span class="sourceLineNo">384</span>        connectionProperties.put(name, value);<a name="line.384"></a>
<span class="sourceLineNo">385</span>    }<a name="line.385"></a>
<span class="sourceLineNo">386</span><a name="line.386"></a>
<span class="sourceLineNo">387</span>    /**<a name="line.387"></a>
<span class="sourceLineNo">388</span>     * &lt;p&gt;<a name="line.388"></a>
<span class="sourceLineNo">389</span>     * Closes and releases all idle connections that are currently stored in the connection pool associated with this<a name="line.389"></a>
<span class="sourceLineNo">390</span>     * data source.<a name="line.390"></a>
<span class="sourceLineNo">391</span>     * &lt;/p&gt;<a name="line.391"></a>
<span class="sourceLineNo">392</span>     * &lt;p&gt;<a name="line.392"></a>
<span class="sourceLineNo">393</span>     * Connections that are checked out to clients when this method is invoked are not affected. When client<a name="line.393"></a>
<span class="sourceLineNo">394</span>     * applications subsequently invoke {@link Connection#close()} to return these connections to the pool, the<a name="line.394"></a>
<span class="sourceLineNo">395</span>     * underlying JDBC connections are closed.<a name="line.395"></a>
<span class="sourceLineNo">396</span>     * &lt;/p&gt;<a name="line.396"></a>
<span class="sourceLineNo">397</span>     * &lt;p&gt;<a name="line.397"></a>
<span class="sourceLineNo">398</span>     * Attempts to acquire connections using {@link #getConnection()} after this method has been invoked result in<a name="line.398"></a>
<span class="sourceLineNo">399</span>     * SQLExceptions.  To reopen a datasource that has been closed using this method, use {@link #start()}.<a name="line.399"></a>
<span class="sourceLineNo">400</span>     * &lt;/p&gt;<a name="line.400"></a>
<span class="sourceLineNo">401</span>     * &lt;p&gt;<a name="line.401"></a>
<span class="sourceLineNo">402</span>     * This method is idempotent - i.e., closing an already closed BasicDataSource has no effect and does not generate<a name="line.402"></a>
<span class="sourceLineNo">403</span>     * exceptions.<a name="line.403"></a>
<span class="sourceLineNo">404</span>     * &lt;/p&gt;<a name="line.404"></a>
<span class="sourceLineNo">405</span>     *<a name="line.405"></a>
<span class="sourceLineNo">406</span>     * @throws SQLException if an error occurs closing idle connections<a name="line.406"></a>
<span class="sourceLineNo">407</span>     */<a name="line.407"></a>
<span class="sourceLineNo">408</span>    @Override<a name="line.408"></a>
<span class="sourceLineNo">409</span>    public synchronized void close() throws SQLException {<a name="line.409"></a>
<span class="sourceLineNo">410</span>        if (registeredJmxObjectName != null) {<a name="line.410"></a>
<span class="sourceLineNo">411</span>            registeredJmxObjectName.unregisterMBean();<a name="line.411"></a>
<span class="sourceLineNo">412</span>            registeredJmxObjectName = null;<a name="line.412"></a>
<span class="sourceLineNo">413</span>        }<a name="line.413"></a>
<span class="sourceLineNo">414</span>        closed = true;<a name="line.414"></a>
<span class="sourceLineNo">415</span>        final GenericObjectPool&lt;?&gt; oldPool = connectionPool;<a name="line.415"></a>
<span class="sourceLineNo">416</span>        connectionPool = null;<a name="line.416"></a>
<span class="sourceLineNo">417</span>        dataSource = null;<a name="line.417"></a>
<span class="sourceLineNo">418</span>        try {<a name="line.418"></a>
<span class="sourceLineNo">419</span>            if (oldPool != null) {<a name="line.419"></a>
<span class="sourceLineNo">420</span>                oldPool.close();<a name="line.420"></a>
<span class="sourceLineNo">421</span>            }<a name="line.421"></a>
<span class="sourceLineNo">422</span>        } catch (final RuntimeException e) {<a name="line.422"></a>
<span class="sourceLineNo">423</span>            throw e;<a name="line.423"></a>
<span class="sourceLineNo">424</span>        } catch (final Exception e) {<a name="line.424"></a>
<span class="sourceLineNo">425</span>            throw new SQLException(Utils.getMessage("pool.close.fail"), e);<a name="line.425"></a>
<span class="sourceLineNo">426</span>        }<a name="line.426"></a>
<span class="sourceLineNo">427</span>    }<a name="line.427"></a>
<span class="sourceLineNo">428</span><a name="line.428"></a>
<span class="sourceLineNo">429</span>    /**<a name="line.429"></a>
<span class="sourceLineNo">430</span>     * Closes the connection pool, silently swallowing any exception that occurs.<a name="line.430"></a>
<span class="sourceLineNo">431</span>     */<a name="line.431"></a>
<span class="sourceLineNo">432</span>    private void closeConnectionPool() {<a name="line.432"></a>
<span class="sourceLineNo">433</span>        final GenericObjectPool&lt;?&gt; oldPool = connectionPool;<a name="line.433"></a>
<span class="sourceLineNo">434</span>        connectionPool = null;<a name="line.434"></a>
<span class="sourceLineNo">435</span>        Utils.closeQuietly(oldPool);<a name="line.435"></a>
<span class="sourceLineNo">436</span>    }<a name="line.436"></a>
<span class="sourceLineNo">437</span><a name="line.437"></a>
<span class="sourceLineNo">438</span>    /**<a name="line.438"></a>
<span class="sourceLineNo">439</span>     * Creates a JDBC connection factory for this data source. The JDBC driver is loaded using the following algorithm:<a name="line.439"></a>
<span class="sourceLineNo">440</span>     * &lt;ol&gt;<a name="line.440"></a>
<span class="sourceLineNo">441</span>     * &lt;li&gt;If a Driver instance has been specified via {@link #setDriver(Driver)} use it&lt;/li&gt;<a name="line.441"></a>
<span class="sourceLineNo">442</span>     * &lt;li&gt;If no Driver instance was specified and {@link #driverClassName} is specified that class is loaded using the<a name="line.442"></a>
<span class="sourceLineNo">443</span>     * {@link ClassLoader} of this class or, if {@link #driverClassLoader} is set, {@link #driverClassName} is loaded<a name="line.443"></a>
<span class="sourceLineNo">444</span>     * with the specified {@link ClassLoader}.&lt;/li&gt;<a name="line.444"></a>
<span class="sourceLineNo">445</span>     * &lt;li&gt;If {@link #driverClassName} is specified and the previous attempt fails, the class is loaded using the<a name="line.445"></a>
<span class="sourceLineNo">446</span>     * context class loader of the current thread.&lt;/li&gt;<a name="line.446"></a>
<span class="sourceLineNo">447</span>     * &lt;li&gt;If a driver still isn't loaded one is loaded via the {@link DriverManager} using the specified {@link #url}.<a name="line.447"></a>
<span class="sourceLineNo">448</span>     * &lt;/ol&gt;<a name="line.448"></a>
<span class="sourceLineNo">449</span>     * &lt;p&gt;<a name="line.449"></a>
<span class="sourceLineNo">450</span>     * This method exists so subclasses can replace the implementation class.<a name="line.450"></a>
<span class="sourceLineNo">451</span>     * &lt;/p&gt;<a name="line.451"></a>
<span class="sourceLineNo">452</span>     *<a name="line.452"></a>
<span class="sourceLineNo">453</span>     * @return A new connection factory.<a name="line.453"></a>
<span class="sourceLineNo">454</span>     *<a name="line.454"></a>
<span class="sourceLineNo">455</span>     * @throws SQLException If the connection factory cannot be created<a name="line.455"></a>
<span class="sourceLineNo">456</span>     */<a name="line.456"></a>
<span class="sourceLineNo">457</span>    protected ConnectionFactory createConnectionFactory() throws SQLException {<a name="line.457"></a>
<span class="sourceLineNo">458</span>        // Load the JDBC driver class<a name="line.458"></a>
<span class="sourceLineNo">459</span>        return ConnectionFactoryFactory.createConnectionFactory(this, DriverFactory.createDriver(this));<a name="line.459"></a>
<span class="sourceLineNo">460</span>    }<a name="line.460"></a>
<span class="sourceLineNo">461</span><a name="line.461"></a>
<span class="sourceLineNo">462</span><a name="line.462"></a>
<span class="sourceLineNo">463</span>    /**<a name="line.463"></a>
<span class="sourceLineNo">464</span>     * Creates a connection pool for this datasource. This method only exists so subclasses can replace the<a name="line.464"></a>
<span class="sourceLineNo">465</span>     * implementation class.<a name="line.465"></a>
<span class="sourceLineNo">466</span>     * &lt;p&gt;<a name="line.466"></a>
<span class="sourceLineNo">467</span>     * This implementation configures all pool properties other than timeBetweenEvictionRunsMillis. Setting that<a name="line.467"></a>
<span class="sourceLineNo">468</span>     * property is deferred to {@link #startPoolMaintenance()}, since setting timeBetweenEvictionRunsMillis to a<a name="line.468"></a>
<span class="sourceLineNo">469</span>     * positive value causes {@link GenericObjectPool}'s eviction timer to be started.<a name="line.469"></a>
<span class="sourceLineNo">470</span>     * &lt;/p&gt;<a name="line.470"></a>
<span class="sourceLineNo">471</span>     *<a name="line.471"></a>
<span class="sourceLineNo">472</span>     * @param factory The factory to use to create new connections for this pool.<a name="line.472"></a>
<span class="sourceLineNo">473</span>     */<a name="line.473"></a>
<span class="sourceLineNo">474</span>    protected void createConnectionPool(final PoolableConnectionFactory factory) {<a name="line.474"></a>
<span class="sourceLineNo">475</span>        // Create an object pool to contain our active connections<a name="line.475"></a>
<span class="sourceLineNo">476</span>        final GenericObjectPoolConfig&lt;PoolableConnection&gt; config = new GenericObjectPoolConfig&lt;&gt;();<a name="line.476"></a>
<span class="sourceLineNo">477</span>        updateJmxName(config);<a name="line.477"></a>
<span class="sourceLineNo">478</span>        // Disable JMX on the underlying pool if the DS is not registered:<a name="line.478"></a>
<span class="sourceLineNo">479</span>        config.setJmxEnabled(registeredJmxObjectName != null);<a name="line.479"></a>
<span class="sourceLineNo">480</span>        final GenericObjectPool&lt;PoolableConnection&gt; gop = createObjectPool(factory, config, abandonedConfig);<a name="line.480"></a>
<span class="sourceLineNo">481</span>        gop.setMaxTotal(maxTotal);<a name="line.481"></a>
<span class="sourceLineNo">482</span>        gop.setMaxIdle(maxIdle);<a name="line.482"></a>
<span class="sourceLineNo">483</span>        gop.setMinIdle(minIdle);<a name="line.483"></a>
<span class="sourceLineNo">484</span>        gop.setMaxWaitMillis(maxWaitMillis);<a name="line.484"></a>
<span class="sourceLineNo">485</span>        gop.setTestOnCreate(testOnCreate);<a name="line.485"></a>
<span class="sourceLineNo">486</span>        gop.setTestOnBorrow(testOnBorrow);<a name="line.486"></a>
<span class="sourceLineNo">487</span>        gop.setTestOnReturn(testOnReturn);<a name="line.487"></a>
<span class="sourceLineNo">488</span>        gop.setNumTestsPerEvictionRun(numTestsPerEvictionRun);<a name="line.488"></a>
<span class="sourceLineNo">489</span>        gop.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);<a name="line.489"></a>
<span class="sourceLineNo">490</span>        gop.setSoftMinEvictableIdleTimeMillis(softMinEvictableIdleTimeMillis);<a name="line.490"></a>
<span class="sourceLineNo">491</span>        gop.setTestWhileIdle(testWhileIdle);<a name="line.491"></a>
<span class="sourceLineNo">492</span>        gop.setLifo(lifo);<a name="line.492"></a>
<span class="sourceLineNo">493</span>        gop.setSwallowedExceptionListener(new SwallowedExceptionLogger(log, logExpiredConnections));<a name="line.493"></a>
<span class="sourceLineNo">494</span>        gop.setEvictionPolicyClassName(evictionPolicyClassName);<a name="line.494"></a>
<span class="sourceLineNo">495</span>        factory.setPool(gop);<a name="line.495"></a>
<span class="sourceLineNo">496</span>        connectionPool = gop;<a name="line.496"></a>
<span class="sourceLineNo">497</span>    }<a name="line.497"></a>
<span class="sourceLineNo">498</span><a name="line.498"></a>
<span class="sourceLineNo">499</span>    /**<a name="line.499"></a>
<span class="sourceLineNo">500</span>     * &lt;p&gt;<a name="line.500"></a>
<span class="sourceLineNo">501</span>     * Creates (if necessary) and return the internal data source we are using to manage our connections.<a name="line.501"></a>
<span class="sourceLineNo">502</span>     * &lt;/p&gt;<a name="line.502"></a>
<span class="sourceLineNo">503</span>     *<a name="line.503"></a>
<span class="sourceLineNo">504</span>     * @return The current internal DataSource or a newly created instance if it has not yet been created.<a name="line.504"></a>
<span class="sourceLineNo">505</span>     * @throws SQLException if the object pool cannot be created.<a name="line.505"></a>
<span class="sourceLineNo">506</span>     */<a name="line.506"></a>
<span class="sourceLineNo">507</span>    protected DataSource createDataSource() throws SQLException {<a name="line.507"></a>
<span class="sourceLineNo">508</span>        if (closed) {<a name="line.508"></a>
<span class="sourceLineNo">509</span>            throw new SQLException("Data source is closed");<a name="line.509"></a>
<span class="sourceLineNo">510</span>        }<a name="line.510"></a>
<span class="sourceLineNo">511</span><a name="line.511"></a>
<span class="sourceLineNo">512</span>        // Return the pool if we have already created it<a name="line.512"></a>
<span class="sourceLineNo">513</span>        // This is double-checked locking. This is safe since dataSource is<a name="line.513"></a>
<span class="sourceLineNo">514</span>        // volatile and the code is targeted at Java 5 onwards.<a name="line.514"></a>
<span class="sourceLineNo">515</span>        if (dataSource != null) {<a name="line.515"></a>
<span class="sourceLineNo">516</span>            return dataSource;<a name="line.516"></a>
<span class="sourceLineNo">517</span>        }<a name="line.517"></a>
<span class="sourceLineNo">518</span>        synchronized (this) {<a name="line.518"></a>
<span class="sourceLineNo">519</span>            if (dataSource != null) {<a name="line.519"></a>
<span class="sourceLineNo">520</span>                return dataSource;<a name="line.520"></a>
<span class="sourceLineNo">521</span>            }<a name="line.521"></a>
<span class="sourceLineNo">522</span>            jmxRegister();<a name="line.522"></a>
<span class="sourceLineNo">523</span><a name="line.523"></a>
<span class="sourceLineNo">524</span>            // create factory which returns raw physical connections<a name="line.524"></a>
<span class="sourceLineNo">525</span>            final ConnectionFactory driverConnectionFactory = createConnectionFactory();<a name="line.525"></a>
<span class="sourceLineNo">526</span><a name="line.526"></a>
<span class="sourceLineNo">527</span>            // Set up the poolable connection factory<a name="line.527"></a>
<span class="sourceLineNo">528</span>            boolean success = false;<a name="line.528"></a>
<span class="sourceLineNo">529</span>            final PoolableConnectionFactory poolableConnectionFactory;<a name="line.529"></a>
<span class="sourceLineNo">530</span>            try {<a name="line.530"></a>
<span class="sourceLineNo">531</span>                poolableConnectionFactory = createPoolableConnectionFactory(driverConnectionFactory);<a name="line.531"></a>
<span class="sourceLineNo">532</span>                poolableConnectionFactory.setPoolStatements(poolPreparedStatements);<a name="line.532"></a>
<span class="sourceLineNo">533</span>                poolableConnectionFactory.setMaxOpenPreparedStatements(maxOpenPreparedStatements);<a name="line.533"></a>
<span class="sourceLineNo">534</span>                success = true;<a name="line.534"></a>
<span class="sourceLineNo">535</span>            } catch (final SQLException | RuntimeException se) {<a name="line.535"></a>
<span class="sourceLineNo">536</span>                throw se;<a name="line.536"></a>
<span class="sourceLineNo">537</span>            } catch (final Exception ex) {<a name="line.537"></a>
<span class="sourceLineNo">538</span>                throw new SQLException("Error creating connection factory", ex);<a name="line.538"></a>
<span class="sourceLineNo">539</span>            }<a name="line.539"></a>
<span class="sourceLineNo">540</span><a name="line.540"></a>
<span class="sourceLineNo">541</span>            if (success) {<a name="line.541"></a>
<span class="sourceLineNo">542</span>                // create a pool for our connections<a name="line.542"></a>
<span class="sourceLineNo">543</span>                createConnectionPool(poolableConnectionFactory);<a name="line.543"></a>
<span class="sourceLineNo">544</span>            }<a name="line.544"></a>
<span class="sourceLineNo">545</span><a name="line.545"></a>
<span class="sourceLineNo">546</span>            // Create the pooling data source to manage connections<a name="line.546"></a>
<span class="sourceLineNo">547</span>            DataSource newDataSource;<a name="line.547"></a>
<span class="sourceLineNo">548</span>            success = false;<a name="line.548"></a>
<span class="sourceLineNo">549</span>            try {<a name="line.549"></a>
<span class="sourceLineNo">550</span>                newDataSource = createDataSourceInstance();<a name="line.550"></a>
<span class="sourceLineNo">551</span>                newDataSource.setLogWriter(logWriter);<a name="line.551"></a>
<span class="sourceLineNo">552</span>                success = true;<a name="line.552"></a>
<span class="sourceLineNo">553</span>            } catch (final SQLException | RuntimeException se) {<a name="line.553"></a>
<span class="sourceLineNo">554</span>                throw se;<a name="line.554"></a>
<span class="sourceLineNo">555</span>            } catch (final Exception ex) {<a name="line.555"></a>
<span class="sourceLineNo">556</span>                throw new SQLException("Error creating datasource", ex);<a name="line.556"></a>
<span class="sourceLineNo">557</span>            } finally {<a name="line.557"></a>
<span class="sourceLineNo">558</span>                if (!success) {<a name="line.558"></a>
<span class="sourceLineNo">559</span>                    closeConnectionPool();<a name="line.559"></a>
<span class="sourceLineNo">560</span>                }<a name="line.560"></a>
<span class="sourceLineNo">561</span>            }<a name="line.561"></a>
<span class="sourceLineNo">562</span><a name="line.562"></a>
<span class="sourceLineNo">563</span>            // If initialSize &gt; 0, preload the pool<a name="line.563"></a>
<span class="sourceLineNo">564</span>            try {<a name="line.564"></a>
<span class="sourceLineNo">565</span>                for (int i = 0; i &lt; initialSize; i++) {<a name="line.565"></a>
<span class="sourceLineNo">566</span>                    connectionPool.addObject();<a name="line.566"></a>
<span class="sourceLineNo">567</span>                }<a name="line.567"></a>
<span class="sourceLineNo">568</span>            } catch (final Exception e) {<a name="line.568"></a>
<span class="sourceLineNo">569</span>                closeConnectionPool();<a name="line.569"></a>
<span class="sourceLineNo">570</span>                throw new SQLException("Error preloading the connection pool", e);<a name="line.570"></a>
<span class="sourceLineNo">571</span>            }<a name="line.571"></a>
<span class="sourceLineNo">572</span><a name="line.572"></a>
<span class="sourceLineNo">573</span>            // If timeBetweenEvictionRunsMillis &gt; 0, start the pool's evictor<a name="line.573"></a>
<span class="sourceLineNo">574</span>            // task<a name="line.574"></a>
<span class="sourceLineNo">575</span>            startPoolMaintenance();<a name="line.575"></a>
<span class="sourceLineNo">576</span><a name="line.576"></a>
<span class="sourceLineNo">577</span>            dataSource = newDataSource;<a name="line.577"></a>
<span class="sourceLineNo">578</span>            return dataSource;<a name="line.578"></a>
<span class="sourceLineNo">579</span>        }<a name="line.579"></a>
<span class="sourceLineNo">580</span>    }<a name="line.580"></a>
<span class="sourceLineNo">581</span><a name="line.581"></a>
<span class="sourceLineNo">582</span>    /**<a name="line.582"></a>
<span class="sourceLineNo">583</span>     * Creates the actual data source instance. This method only exists so that subclasses can replace the<a name="line.583"></a>
<span class="sourceLineNo">584</span>     * implementation class.<a name="line.584"></a>
<span class="sourceLineNo">585</span>     *<a name="line.585"></a>
<span class="sourceLineNo">586</span>     * @throws SQLException if unable to create a datasource instance<a name="line.586"></a>
<span class="sourceLineNo">587</span>     *<a name="line.587"></a>
<span class="sourceLineNo">588</span>     * @return A new DataSource instance<a name="line.588"></a>
<span class="sourceLineNo">589</span>     */<a name="line.589"></a>
<span class="sourceLineNo">590</span>    protected DataSource createDataSourceInstance() throws SQLException {<a name="line.590"></a>
<span class="sourceLineNo">591</span>        final PoolingDataSource&lt;PoolableConnection&gt; pds = new PoolingDataSource&lt;&gt;(connectionPool);<a name="line.591"></a>
<span class="sourceLineNo">592</span>        pds.setAccessToUnderlyingConnectionAllowed(isAccessToUnderlyingConnectionAllowed());<a name="line.592"></a>
<span class="sourceLineNo">593</span>        return pds;<a name="line.593"></a>
<span class="sourceLineNo">594</span>    }<a name="line.594"></a>
<span class="sourceLineNo">595</span><a name="line.595"></a>
<span class="sourceLineNo">596</span>    /**<a name="line.596"></a>
<span class="sourceLineNo">597</span>     * Creates an object pool used to provide pooling support for {@link Connection JDBC connections}.<a name="line.597"></a>
<span class="sourceLineNo">598</span>     *<a name="line.598"></a>
<span class="sourceLineNo">599</span>     * @param factory         the object factory<a name="line.599"></a>
<span class="sourceLineNo">600</span>     * @param poolConfig      the object pool configuration<a name="line.600"></a>
<span class="sourceLineNo">601</span>     * @param abandonedConfig the abandoned objects configuration<a name="line.601"></a>
<span class="sourceLineNo">602</span>     * @return a non-null instance<a name="line.602"></a>
<span class="sourceLineNo">603</span>     */<a name="line.603"></a>
<span class="sourceLineNo">604</span>    protected GenericObjectPool&lt;PoolableConnection&gt; createObjectPool(final PoolableConnectionFactory factory,<a name="line.604"></a>
<span class="sourceLineNo">605</span>            final GenericObjectPoolConfig&lt;PoolableConnection&gt; poolConfig, final AbandonedConfig abandonedConfig) {<a name="line.605"></a>
<span class="sourceLineNo">606</span>        final GenericObjectPool&lt;PoolableConnection&gt; gop;<a name="line.606"></a>
<span class="sourceLineNo">607</span>        if (abandonedConfig != null &amp;&amp; (abandonedConfig.getRemoveAbandonedOnBorrow()<a name="line.607"></a>
<span class="sourceLineNo">608</span>                || abandonedConfig.getRemoveAbandonedOnMaintenance())) {<a name="line.608"></a>
<span class="sourceLineNo">609</span>            gop = new GenericObjectPool&lt;&gt;(factory, poolConfig, abandonedConfig);<a name="line.609"></a>
<span class="sourceLineNo">610</span>        } else {<a name="line.610"></a>
<span class="sourceLineNo">611</span>            gop = new GenericObjectPool&lt;&gt;(factory, poolConfig);<a name="line.611"></a>
<span class="sourceLineNo">612</span>        }<a name="line.612"></a>
<span class="sourceLineNo">613</span>        return gop;<a name="line.613"></a>
<span class="sourceLineNo">614</span>    }<a name="line.614"></a>
<span class="sourceLineNo">615</span><a name="line.615"></a>
<span class="sourceLineNo">616</span>    /**<a name="line.616"></a>
<span class="sourceLineNo">617</span>     * Creates the PoolableConnectionFactory and attaches it to the connection pool. This method only exists so<a name="line.617"></a>
<span class="sourceLineNo">618</span>     * subclasses can replace the default implementation.<a name="line.618"></a>
<span class="sourceLineNo">619</span>     *<a name="line.619"></a>
<span class="sourceLineNo">620</span>     * @param driverConnectionFactory JDBC connection factory<a name="line.620"></a>
<span class="sourceLineNo">621</span>     * @throws SQLException if an error occurs creating the PoolableConnectionFactory<a name="line.621"></a>
<span class="sourceLineNo">622</span>     *<a name="line.622"></a>
<span class="sourceLineNo">623</span>     * @return A new PoolableConnectionFactory configured with the current configuration of this BasicDataSource<a name="line.623"></a>
<span class="sourceLineNo">624</span>     */<a name="line.624"></a>
<span class="sourceLineNo">625</span>    protected PoolableConnectionFactory createPoolableConnectionFactory(final ConnectionFactory driverConnectionFactory)<a name="line.625"></a>
<span class="sourceLineNo">626</span>            throws SQLException {<a name="line.626"></a>
<span class="sourceLineNo">627</span>        PoolableConnectionFactory connectionFactory = null;<a name="line.627"></a>
<span class="sourceLineNo">628</span>        try {<a name="line.628"></a>
<span class="sourceLineNo">629</span>            connectionFactory = new PoolableConnectionFactory(driverConnectionFactory,<a name="line.629"></a>
<span class="sourceLineNo">630</span>                    ObjectNameWrapper.unwrap(registeredJmxObjectName));<a name="line.630"></a>
<span class="sourceLineNo">631</span>            connectionFactory.setValidationQuery(validationQuery);<a name="line.631"></a>
<span class="sourceLineNo">632</span>            connectionFactory.setValidationQueryTimeout(validationQueryTimeoutSeconds);<a name="line.632"></a>
<span class="sourceLineNo">633</span>            connectionFactory.setConnectionInitSql(connectionInitSqls);<a name="line.633"></a>
<span class="sourceLineNo">634</span>            connectionFactory.setDefaultReadOnly(defaultReadOnly);<a name="line.634"></a>
<span class="sourceLineNo">635</span>            connectionFactory.setDefaultAutoCommit(defaultAutoCommit);<a name="line.635"></a>
<span class="sourceLineNo">636</span>            connectionFactory.setDefaultTransactionIsolation(defaultTransactionIsolation);<a name="line.636"></a>
<span class="sourceLineNo">637</span>            connectionFactory.setDefaultCatalog(defaultCatalog);<a name="line.637"></a>
<span class="sourceLineNo">638</span>            connectionFactory.setDefaultSchema(defaultSchema);<a name="line.638"></a>
<span class="sourceLineNo">639</span>            connectionFactory.setCacheState(cacheState);<a name="line.639"></a>
<span class="sourceLineNo">640</span>            connectionFactory.setPoolStatements(poolPreparedStatements);<a name="line.640"></a>
<span class="sourceLineNo">641</span>            connectionFactory.setClearStatementPoolOnReturn(clearStatementPoolOnReturn);<a name="line.641"></a>
<span class="sourceLineNo">642</span>            connectionFactory.setMaxOpenPreparedStatements(maxOpenPreparedStatements);<a name="line.642"></a>
<span class="sourceLineNo">643</span>            connectionFactory.setMaxConnLifetimeMillis(maxConnLifetimeMillis);<a name="line.643"></a>
<span class="sourceLineNo">644</span>            connectionFactory.setRollbackOnReturn(getRollbackOnReturn());<a name="line.644"></a>
<span class="sourceLineNo">645</span>            connectionFactory.setAutoCommitOnReturn(getAutoCommitOnReturn());<a name="line.645"></a>
<span class="sourceLineNo">646</span>            connectionFactory.setDefaultQueryTimeout(getDefaultQueryTimeout());<a name="line.646"></a>
<span class="sourceLineNo">647</span>            connectionFactory.setFastFailValidation(fastFailValidation);<a name="line.647"></a>
<span class="sourceLineNo">648</span>            connectionFactory.setDisconnectionSqlCodes(disconnectionSqlCodes);<a name="line.648"></a>
<span class="sourceLineNo">649</span>            validateConnectionFactory(connectionFactory);<a name="line.649"></a>
<span class="sourceLineNo">650</span>        } catch (final RuntimeException e) {<a name="line.650"></a>
<span class="sourceLineNo">651</span>            throw e;<a name="line.651"></a>
<span class="sourceLineNo">652</span>        } catch (final Exception e) {<a name="line.652"></a>
<span class="sourceLineNo">653</span>            throw new SQLException("Cannot create PoolableConnectionFactory (" + e.getMessage() + ")", e);<a name="line.653"></a>
<span class="sourceLineNo">654</span>        }<a name="line.654"></a>
<span class="sourceLineNo">655</span>        return connectionFactory;<a name="line.655"></a>
<span class="sourceLineNo">656</span>    }<a name="line.656"></a>
<span class="sourceLineNo">657</span><a name="line.657"></a>
<span class="sourceLineNo">658</span>    /**<a name="line.658"></a>
<span class="sourceLineNo">659</span>     * Manually evicts idle connections<a name="line.659"></a>
<span class="sourceLineNo">660</span>     *<a name="line.660"></a>
<span class="sourceLineNo">661</span>     * @throws Exception when there is a problem evicting idle objects.<a name="line.661"></a>
<span class="sourceLineNo">662</span>     */<a name="line.662"></a>
<span class="sourceLineNo">663</span>    public void evict() throws Exception {<a name="line.663"></a>
<span class="sourceLineNo">664</span>        if (connectionPool != null) {<a name="line.664"></a>
<span class="sourceLineNo">665</span>            connectionPool.evict();<a name="line.665"></a>
<span class="sourceLineNo">666</span>        }<a name="line.666"></a>
<span class="sourceLineNo">667</span>    }<a name="line.667"></a>
<span class="sourceLineNo">668</span><a name="line.668"></a>
<span class="sourceLineNo">669</span>    /**<a name="line.669"></a>
<span class="sourceLineNo">670</span>     * Gets the print writer used by this configuration to log information on abandoned objects.<a name="line.670"></a>
<span class="sourceLineNo">671</span>     *<a name="line.671"></a>
<span class="sourceLineNo">672</span>     * @return The print writer used by this configuration to log information on abandoned objects.<a name="line.672"></a>
<span class="sourceLineNo">673</span>     */<a name="line.673"></a>
<span class="sourceLineNo">674</span>    public PrintWriter getAbandonedLogWriter() {<a name="line.674"></a>
<span class="sourceLineNo">675</span>        return abandonedConfig == null ? null : abandonedConfig.getLogWriter();<a name="line.675"></a>
<span class="sourceLineNo">676</span>    }<a name="line.676"></a>
<span class="sourceLineNo">677</span><a name="line.677"></a>
<span class="sourceLineNo">678</span>    /**<a name="line.678"></a>
<span class="sourceLineNo">679</span>     * If the connection pool implements {@link org.apache.commons.pool2.UsageTracking UsageTracking}, should the<a name="line.679"></a>
<span class="sourceLineNo">680</span>     * connection pool record a stack trace every time a method is called on a pooled connection and retain the most<a name="line.680"></a>
<span class="sourceLineNo">681</span>     * recent stack trace to aid debugging of abandoned connections?<a name="line.681"></a>
<span class="sourceLineNo">682</span>     *<a name="line.682"></a>
<span class="sourceLineNo">683</span>     * @return &lt;code&gt;true&lt;/code&gt; if usage tracking is enabled<a name="line.683"></a>
<span class="sourceLineNo">684</span>     */<a name="line.684"></a>
<span class="sourceLineNo">685</span>    @Override<a name="line.685"></a>
<span class="sourceLineNo">686</span>    public boolean getAbandonedUsageTracking() {<a name="line.686"></a>
<span class="sourceLineNo">687</span>        return abandonedConfig != null &amp;&amp; abandonedConfig.getUseUsageTracking();<a name="line.687"></a>
<span class="sourceLineNo">688</span>    }<a name="line.688"></a>
<span class="sourceLineNo">689</span><a name="line.689"></a>
<span class="sourceLineNo">690</span>    /**<a name="line.690"></a>
<span class="sourceLineNo">691</span>     * Returns the value of the flag that controls whether or not connections being returned to the pool will be checked<a name="line.691"></a>
<span class="sourceLineNo">692</span>     * and configured with {@link Connection#setAutoCommit(boolean) Connection.setAutoCommit(true)} if the auto commit<a name="line.692"></a>
<span class="sourceLineNo">693</span>     * setting is {@code false} when the connection is returned. It is &lt;code&gt;true&lt;/code&gt; by default.<a name="line.693"></a>
<span class="sourceLineNo">694</span>     *<a name="line.694"></a>
<span class="sourceLineNo">695</span>     * @return Whether or not connections being returned to the pool will be checked and configured with auto-commit.<a name="line.695"></a>
<span class="sourceLineNo">696</span>     */<a name="line.696"></a>
<span class="sourceLineNo">697</span>    public boolean getAutoCommitOnReturn() {<a name="line.697"></a>
<span class="sourceLineNo">698</span>        return autoCommitOnReturn;<a name="line.698"></a>
<span class="sourceLineNo">699</span>    }<a name="line.699"></a>
<span class="sourceLineNo">700</span><a name="line.700"></a>
<span class="sourceLineNo">701</span>    /**<a name="line.701"></a>
<span class="sourceLineNo">702</span>     * Returns the state caching flag.<a name="line.702"></a>
<span class="sourceLineNo">703</span>     *<a name="line.703"></a>
<span class="sourceLineNo">704</span>     * @return the state caching flag<a name="line.704"></a>
<span class="sourceLineNo">705</span>     */<a name="line.705"></a>
<span class="sourceLineNo">706</span>    @Override<a name="line.706"></a>
<span class="sourceLineNo">707</span>    public boolean getCacheState() {<a name="line.707"></a>
<span class="sourceLineNo">708</span>        return cacheState;<a name="line.708"></a>
<span class="sourceLineNo">709</span>    }<a name="line.709"></a>
<span class="sourceLineNo">710</span><a name="line.710"></a>
<span class="sourceLineNo">711</span>    /**<a name="line.711"></a>
<span class="sourceLineNo">712</span>     * Creates (if necessary) and return a connection to the database.<a name="line.712"></a>
<span class="sourceLineNo">713</span>     *<a name="line.713"></a>
<span class="sourceLineNo">714</span>     * @throws SQLException if a database access error occurs<a name="line.714"></a>
<span class="sourceLineNo">715</span>     * @return a database connection<a name="line.715"></a>
<span class="sourceLineNo">716</span>     */<a name="line.716"></a>
<span class="sourceLineNo">717</span>    @Override<a name="line.717"></a>
<span class="sourceLineNo">718</span>    public Connection getConnection() throws SQLException {<a name="line.718"></a>
<span class="sourceLineNo">719</span>        if (Utils.isSecurityEnabled()) {<a name="line.719"></a>
<span class="sourceLineNo">720</span>            final PrivilegedExceptionAction&lt;Connection&gt; action = () -&gt; createDataSource().getConnection();<a name="line.720"></a>
<span class="sourceLineNo">721</span>            try {<a name="line.721"></a>
<span class="sourceLineNo">722</span>                return AccessController.doPrivileged(action);<a name="line.722"></a>
<span class="sourceLineNo">723</span>            } catch (final PrivilegedActionException e) {<a name="line.723"></a>
<span class="sourceLineNo">724</span>                final Throwable cause = e.getCause();<a name="line.724"></a>
<span class="sourceLineNo">725</span>                if (cause instanceof SQLException) {<a name="line.725"></a>
<span class="sourceLineNo">726</span>                    throw (SQLException) cause;<a name="line.726"></a>
<span class="sourceLineNo">727</span>                }<a name="line.727"></a>
<span class="sourceLineNo">728</span>                throw new SQLException(e);<a name="line.728"></a>
<span class="sourceLineNo">729</span>            }<a name="line.729"></a>
<span class="sourceLineNo">730</span>        }<a name="line.730"></a>
<span class="sourceLineNo">731</span>        return createDataSource().getConnection();<a name="line.731"></a>
<span class="sourceLineNo">732</span>    }<a name="line.732"></a>
<span class="sourceLineNo">733</span><a name="line.733"></a>
<span class="sourceLineNo">734</span>    /**<a name="line.734"></a>
<span class="sourceLineNo">735</span>     * &lt;strong&gt;BasicDataSource does NOT support this method.&lt;/strong&gt;<a name="line.735"></a>
<span class="sourceLineNo">736</span>     *<a name="line.736"></a>
<span class="sourceLineNo">737</span>     * @param user Database user on whose behalf the Connection is being made<a name="line.737"></a>
<span class="sourceLineNo">738</span>     * @param pass The database user's password<a name="line.738"></a>
<span class="sourceLineNo">739</span>     *<a name="line.739"></a>
<span class="sourceLineNo">740</span>     * @throws UnsupportedOperationException always thrown.<a name="line.740"></a>
<span class="sourceLineNo">741</span>     * @throws SQLException                  if a database access error occurs<a name="line.741"></a>
<span class="sourceLineNo">742</span>     * @return nothing - always throws UnsupportedOperationException<a name="line.742"></a>
<span class="sourceLineNo">743</span>     */<a name="line.743"></a>
<span class="sourceLineNo">744</span>    @Override<a name="line.744"></a>
<span class="sourceLineNo">745</span>    public Connection getConnection(final String user, final String pass) throws SQLException {<a name="line.745"></a>
<span class="sourceLineNo">746</span>        // This method isn't supported by the PoolingDataSource returned by the<a name="line.746"></a>
<span class="sourceLineNo">747</span>        // createDataSource<a name="line.747"></a>
<span class="sourceLineNo">748</span>        throw new UnsupportedOperationException("Not supported by BasicDataSource");<a name="line.748"></a>
<span class="sourceLineNo">749</span>    }<a name="line.749"></a>
<span class="sourceLineNo">750</span><a name="line.750"></a>
<span class="sourceLineNo">751</span>    /**<a name="line.751"></a>
<span class="sourceLineNo">752</span>     * Returns the ConnectionFactoryClassName that has been configured for use by this pool.<a name="line.752"></a>
<span class="sourceLineNo">753</span>     * &lt;p&gt;<a name="line.753"></a>
<span class="sourceLineNo">754</span>     * Note: This getter only returns the last value set by a call to {@link #setConnectionFactoryClassName(String)}.<a name="line.754"></a>
<span class="sourceLineNo">755</span>     * &lt;/p&gt;<a name="line.755"></a>
<span class="sourceLineNo">756</span>     *<a name="line.756"></a>
<span class="sourceLineNo">757</span>     * @return the ConnectionFactoryClassName that has been configured for use by this pool.<a name="line.757"></a>
<span class="sourceLineNo">758</span>     * @since 2.7.0<a name="line.758"></a>
<span class="sourceLineNo">759</span>     */<a name="line.759"></a>
<span class="sourceLineNo">760</span>    public String getConnectionFactoryClassName() {<a name="line.760"></a>
<span class="sourceLineNo">761</span>        return this.connectionFactoryClassName;<a name="line.761"></a>
<span class="sourceLineNo">762</span>    }<a name="line.762"></a>
<span class="sourceLineNo">763</span><a name="line.763"></a>
<span class="sourceLineNo">764</span>    /**<a name="line.764"></a>
<span class="sourceLineNo">765</span>     * Returns the list of SQL statements executed when a physical connection is first created. Returns an empty list if<a name="line.765"></a>
<span class="sourceLineNo">766</span>     * there are no initialization statements configured.<a name="line.766"></a>
<span class="sourceLineNo">767</span>     *<a name="line.767"></a>
<span class="sourceLineNo">768</span>     * @return initialization SQL statements<a name="line.768"></a>
<span class="sourceLineNo">769</span>     */<a name="line.769"></a>
<span class="sourceLineNo">770</span>    public List&lt;String&gt; getConnectionInitSqls() {<a name="line.770"></a>
<span class="sourceLineNo">771</span>        final List&lt;String&gt; result = connectionInitSqls;<a name="line.771"></a>
<span class="sourceLineNo">772</span>        return result == null ? Collections.emptyList() : result;<a name="line.772"></a>
<span class="sourceLineNo">773</span>    }<a name="line.773"></a>
<span class="sourceLineNo">774</span><a name="line.774"></a>
<span class="sourceLineNo">775</span>    /**<a name="line.775"></a>
<span class="sourceLineNo">776</span>     * Provides the same data as {@link #getConnectionInitSqls()} but in an array so it is accessible via JMX.<a name="line.776"></a>
<span class="sourceLineNo">777</span>     */<a name="line.777"></a>
<span class="sourceLineNo">778</span>    @Override<a name="line.778"></a>
<span class="sourceLineNo">779</span>    public String[] getConnectionInitSqlsAsArray() {<a name="line.779"></a>
<span class="sourceLineNo">780</span>        return getConnectionInitSqls().toArray(Utils.EMPTY_STRING_ARRAY);<a name="line.780"></a>
<span class="sourceLineNo">781</span>    }<a name="line.781"></a>
<span class="sourceLineNo">782</span><a name="line.782"></a>
<span class="sourceLineNo">783</span>    protected GenericObjectPool&lt;PoolableConnection&gt; getConnectionPool() {<a name="line.783"></a>
<span class="sourceLineNo">784</span>        return connectionPool;<a name="line.784"></a>
<span class="sourceLineNo">785</span>    }<a name="line.785"></a>
<span class="sourceLineNo">786</span><a name="line.786"></a>
<span class="sourceLineNo">787</span>    Properties getConnectionProperties() {<a name="line.787"></a>
<span class="sourceLineNo">788</span>        return connectionProperties;<a name="line.788"></a>
<span class="sourceLineNo">789</span>    }<a name="line.789"></a>
<span class="sourceLineNo">790</span><a name="line.790"></a>
<span class="sourceLineNo">791</span>    /**<a name="line.791"></a>
<span class="sourceLineNo">792</span>     * Returns the default auto-commit property.<a name="line.792"></a>
<span class="sourceLineNo">793</span>     *<a name="line.793"></a>
<span class="sourceLineNo">794</span>     * @return true if default auto-commit is enabled<a name="line.794"></a>
<span class="sourceLineNo">795</span>     */<a name="line.795"></a>
<span class="sourceLineNo">796</span>    @Override<a name="line.796"></a>
<span class="sourceLineNo">797</span>    public Boolean getDefaultAutoCommit() {<a name="line.797"></a>
<span class="sourceLineNo">798</span>        return defaultAutoCommit;<a name="line.798"></a>
<span class="sourceLineNo">799</span>    }<a name="line.799"></a>
<span class="sourceLineNo">800</span><a name="line.800"></a>
<span class="sourceLineNo">801</span>    /**<a name="line.801"></a>
<span class="sourceLineNo">802</span>     * Returns the default catalog.<a name="line.802"></a>
<span class="sourceLineNo">803</span>     *<a name="line.803"></a>
<span class="sourceLineNo">804</span>     * @return the default catalog<a name="line.804"></a>
<span class="sourceLineNo">805</span>     */<a name="line.805"></a>
<span class="sourceLineNo">806</span>    @Override<a name="line.806"></a>
<span class="sourceLineNo">807</span>    public String getDefaultCatalog() {<a name="line.807"></a>
<span class="sourceLineNo">808</span>        return this.defaultCatalog;<a name="line.808"></a>
<span class="sourceLineNo">809</span>    }<a name="line.809"></a>
<span class="sourceLineNo">810</span><a name="line.810"></a>
<span class="sourceLineNo">811</span>    /**<a name="line.811"></a>
<span class="sourceLineNo">812</span>     * Gets the default query timeout that will be used for {@link java.sql.Statement Statement}s created from this<a name="line.812"></a>
<span class="sourceLineNo">813</span>     * connection. &lt;code&gt;null&lt;/code&gt; means that the driver default will be used.<a name="line.813"></a>
<span class="sourceLineNo">814</span>     *<a name="line.814"></a>
<span class="sourceLineNo">815</span>     * @return The default query timeout in seconds.<a name="line.815"></a>
<span class="sourceLineNo">816</span>     */<a name="line.816"></a>
<span class="sourceLineNo">817</span>    public Integer getDefaultQueryTimeout() {<a name="line.817"></a>
<span class="sourceLineNo">818</span>        return defaultQueryTimeoutSeconds;<a name="line.818"></a>
<span class="sourceLineNo">819</span>    }<a name="line.819"></a>
<span class="sourceLineNo">820</span><a name="line.820"></a>
<span class="sourceLineNo">821</span>    /**<a name="line.821"></a>
<span class="sourceLineNo">822</span>     * Returns the default readOnly property.<a name="line.822"></a>
<span class="sourceLineNo">823</span>     *<a name="line.823"></a>
<span class="sourceLineNo">824</span>     * @return true if connections are readOnly by default<a name="line.824"></a>
<span class="sourceLineNo">825</span>     */<a name="line.825"></a>
<span class="sourceLineNo">826</span>    @Override<a name="line.826"></a>
<span class="sourceLineNo">827</span>    public Boolean getDefaultReadOnly() {<a name="line.827"></a>
<span class="sourceLineNo">828</span>        return defaultReadOnly;<a name="line.828"></a>
<span class="sourceLineNo">829</span>    }<a name="line.829"></a>
<span class="sourceLineNo">830</span><a name="line.830"></a>
<span class="sourceLineNo">831</span>    /**<a name="line.831"></a>
<span class="sourceLineNo">832</span>     * Returns the default schema.<a name="line.832"></a>
<span class="sourceLineNo">833</span>     *<a name="line.833"></a>
<span class="sourceLineNo">834</span>     * @return the default schema.<a name="line.834"></a>
<span class="sourceLineNo">835</span>     * @since 2.5.0<a name="line.835"></a>
<span class="sourceLineNo">836</span>     */<a name="line.836"></a>
<span class="sourceLineNo">837</span>    @Override<a name="line.837"></a>
<span class="sourceLineNo">838</span>    public String getDefaultSchema() {<a name="line.838"></a>
<span class="sourceLineNo">839</span>        return this.defaultSchema;<a name="line.839"></a>
<span class="sourceLineNo">840</span>    }<a name="line.840"></a>
<span class="sourceLineNo">841</span><a name="line.841"></a>
<span class="sourceLineNo">842</span>    /**<a name="line.842"></a>
<span class="sourceLineNo">843</span>     * Returns the default transaction isolation state of returned connections.<a name="line.843"></a>
<span class="sourceLineNo">844</span>     *<a name="line.844"></a>
<span class="sourceLineNo">845</span>     * @return the default value for transaction isolation state<a name="line.845"></a>
<span class="sourceLineNo">846</span>     * @see Connection#getTransactionIsolation<a name="line.846"></a>
<span class="sourceLineNo">847</span>     */<a name="line.847"></a>
<span class="sourceLineNo">848</span>    @Override<a name="line.848"></a>
<span class="sourceLineNo">849</span>    public int getDefaultTransactionIsolation() {<a name="line.849"></a>
<span class="sourceLineNo">850</span>        return this.defaultTransactionIsolation;<a name="line.850"></a>
<span class="sourceLineNo">851</span>    }<a name="line.851"></a>
<span class="sourceLineNo">852</span><a name="line.852"></a>
<span class="sourceLineNo">853</span>    /**<a name="line.853"></a>
<span class="sourceLineNo">854</span>     * Returns the set of SQL_STATE codes considered to signal fatal conditions.<a name="line.854"></a>
<span class="sourceLineNo">855</span>     *<a name="line.855"></a>
<span class="sourceLineNo">856</span>     * @return fatal disconnection state codes<a name="line.856"></a>
<span class="sourceLineNo">857</span>     * @see #setDisconnectionSqlCodes(Collection)<a name="line.857"></a>
<span class="sourceLineNo">858</span>     * @since 2.1<a name="line.858"></a>
<span class="sourceLineNo">859</span>     */<a name="line.859"></a>
<span class="sourceLineNo">860</span>    public Set&lt;String&gt; getDisconnectionSqlCodes() {<a name="line.860"></a>
<span class="sourceLineNo">861</span>        final Set&lt;String&gt; result = disconnectionSqlCodes;<a name="line.861"></a>
<span class="sourceLineNo">862</span>        return result == null ? Collections.emptySet() : result;<a name="line.862"></a>
<span class="sourceLineNo">863</span>    }<a name="line.863"></a>
<span class="sourceLineNo">864</span><a name="line.864"></a>
<span class="sourceLineNo">865</span>    /**<a name="line.865"></a>
<span class="sourceLineNo">866</span>     * Provides the same data as {@link #getDisconnectionSqlCodes} but in an array so it is accessible via JMX.<a name="line.866"></a>
<span class="sourceLineNo">867</span>     *<a name="line.867"></a>
<span class="sourceLineNo">868</span>     * @since 2.1<a name="line.868"></a>
<span class="sourceLineNo">869</span>     */<a name="line.869"></a>
<span class="sourceLineNo">870</span>    @Override<a name="line.870"></a>
<span class="sourceLineNo">871</span>    public String[] getDisconnectionSqlCodesAsArray() {<a name="line.871"></a>
<span class="sourceLineNo">872</span>        return getDisconnectionSqlCodes().toArray(Utils.EMPTY_STRING_ARRAY);<a name="line.872"></a>
<span class="sourceLineNo">873</span>    }<a name="line.873"></a>
<span class="sourceLineNo">874</span><a name="line.874"></a>
<span class="sourceLineNo">875</span>    /**<a name="line.875"></a>
<span class="sourceLineNo">876</span>     * Returns the JDBC Driver that has been configured for use by this pool.<a name="line.876"></a>
<span class="sourceLineNo">877</span>     * &lt;p&gt;<a name="line.877"></a>
<span class="sourceLineNo">878</span>     * Note: This getter only returns the last value set by a call to {@link #setDriver(Driver)}. It does not return any<a name="line.878"></a>
<span class="sourceLineNo">879</span>     * driver instance that may have been created from the value set via {@link #setDriverClassName(String)}.<a name="line.879"></a>
<span class="sourceLineNo">880</span>     * &lt;/p&gt;<a name="line.880"></a>
<span class="sourceLineNo">881</span>     *<a name="line.881"></a>
<span class="sourceLineNo">882</span>     * @return the JDBC Driver that has been configured for use by this pool<a name="line.882"></a>
<span class="sourceLineNo">883</span>     */<a name="line.883"></a>
<span class="sourceLineNo">884</span>    public synchronized Driver getDriver() {<a name="line.884"></a>
<span class="sourceLineNo">885</span>        return driver;<a name="line.885"></a>
<span class="sourceLineNo">886</span>    }<a name="line.886"></a>
<span class="sourceLineNo">887</span><a name="line.887"></a>
<span class="sourceLineNo">888</span>    /**<a name="line.888"></a>
<span class="sourceLineNo">889</span>     * Returns the class loader specified for loading the JDBC driver. Returns &lt;code&gt;null&lt;/code&gt; if no class loader has<a name="line.889"></a>
<span class="sourceLineNo">890</span>     * been explicitly specified.<a name="line.890"></a>
<span class="sourceLineNo">891</span>     * &lt;p&gt;<a name="line.891"></a>
<span class="sourceLineNo">892</span>     * Note: This getter only returns the last value set by a call to {@link #setDriverClassLoader(ClassLoader)}. It<a name="line.892"></a>
<span class="sourceLineNo">893</span>     * does not return the class loader of any driver that may have been set via {@link #setDriver(Driver)}.<a name="line.893"></a>
<span class="sourceLineNo">894</span>     * &lt;/p&gt;<a name="line.894"></a>
<span class="sourceLineNo">895</span>     *<a name="line.895"></a>
<span class="sourceLineNo">896</span>     * @return The class loader specified for loading the JDBC driver.<a name="line.896"></a>
<span class="sourceLineNo">897</span>     */<a name="line.897"></a>
<span class="sourceLineNo">898</span>    public synchronized ClassLoader getDriverClassLoader() {<a name="line.898"></a>
<span class="sourceLineNo">899</span>        return this.driverClassLoader;<a name="line.899"></a>
<span class="sourceLineNo">900</span>    }<a name="line.900"></a>
<span class="sourceLineNo">901</span><a name="line.901"></a>
<span class="sourceLineNo">902</span>    /**<a name="line.902"></a>
<span class="sourceLineNo">903</span>     * Returns the JDBC driver class name.<a name="line.903"></a>
<span class="sourceLineNo">904</span>     * &lt;p&gt;<a name="line.904"></a>
<span class="sourceLineNo">905</span>     * Note: This getter only returns the last value set by a call to {@link #setDriverClassName(String)}. It does not<a name="line.905"></a>
<span class="sourceLineNo">906</span>     * return the class name of any driver that may have been set via {@link #setDriver(Driver)}.<a name="line.906"></a>
<span class="sourceLineNo">907</span>     * &lt;/p&gt;<a name="line.907"></a>
<span class="sourceLineNo">908</span>     *<a name="line.908"></a>
<span class="sourceLineNo">909</span>     * @return the JDBC driver class name<a name="line.909"></a>
<span class="sourceLineNo">910</span>     */<a name="line.910"></a>
<span class="sourceLineNo">911</span>    @Override<a name="line.911"></a>
<span class="sourceLineNo">912</span>    public synchronized String getDriverClassName() {<a name="line.912"></a>
<span class="sourceLineNo">913</span>        return this.driverClassName;<a name="line.913"></a>
<span class="sourceLineNo">914</span>    }<a name="line.914"></a>
<span class="sourceLineNo">915</span><a name="line.915"></a>
<span class="sourceLineNo">916</span>    /**<a name="line.916"></a>
<span class="sourceLineNo">917</span>     * Returns the value of the flag that controls whether or not connections being returned to the pool will be checked<a name="line.917"></a>
<span class="sourceLineNo">918</span>     * and configured with {@link Connection#setAutoCommit(boolean) Connection.setAutoCommit(true)} if the auto commit<a name="line.918"></a>
<span class="sourceLineNo">919</span>     * setting is {@code false} when the connection is returned. It is &lt;code&gt;true&lt;/code&gt; by default.<a name="line.919"></a>
<span class="sourceLineNo">920</span>     *<a name="line.920"></a>
<span class="sourceLineNo">921</span>     * @return Whether or not connections being returned to the pool will be checked and configured with auto-commit.<a name="line.921"></a>
<span class="sourceLineNo">922</span>     * @deprecated Use {@link #getAutoCommitOnReturn()}.<a name="line.922"></a>
<span class="sourceLineNo">923</span>     */<a name="line.923"></a>
<span class="sourceLineNo">924</span>    @Deprecated<a name="line.924"></a>
<span class="sourceLineNo">925</span>    public boolean getEnableAutoCommitOnReturn() {<a name="line.925"></a>
<span class="sourceLineNo">926</span>        return autoCommitOnReturn;<a name="line.926"></a>
<span class="sourceLineNo">927</span>    }<a name="line.927"></a>
<span class="sourceLineNo">928</span><a name="line.928"></a>
<span class="sourceLineNo">929</span>    /**<a name="line.929"></a>
<span class="sourceLineNo">930</span>     * Gets the EvictionPolicy implementation in use with this connection pool.<a name="line.930"></a>
<span class="sourceLineNo">931</span>     *<a name="line.931"></a>
<span class="sourceLineNo">932</span>     * @return The EvictionPolicy implementation in use with this connection pool.<a name="line.932"></a>
<span class="sourceLineNo">933</span>     */<a name="line.933"></a>
<span class="sourceLineNo">934</span>    public synchronized String getEvictionPolicyClassName() {<a name="line.934"></a>
<span class="sourceLineNo">935</span>        return evictionPolicyClassName;<a name="line.935"></a>
<span class="sourceLineNo">936</span>    }<a name="line.936"></a>
<span class="sourceLineNo">937</span><a name="line.937"></a>
<span class="sourceLineNo">938</span>    /**<a name="line.938"></a>
<span class="sourceLineNo">939</span>     * True means that validation will fail immediately for connections that have previously thrown SQLExceptions with<a name="line.939"></a>
<span class="sourceLineNo">940</span>     * SQL_STATE indicating fatal disconnection errors.<a name="line.940"></a>
<span class="sourceLineNo">941</span>     *<a name="line.941"></a>
<span class="sourceLineNo">942</span>     * @return true if connections created by this datasource will fast fail validation.<a name="line.942"></a>
<span class="sourceLineNo">943</span>     * @see #setDisconnectionSqlCodes(Collection)<a name="line.943"></a>
<span class="sourceLineNo">944</span>     * @since 2.1<a name="line.944"></a>
<span class="sourceLineNo">945</span>     */<a name="line.945"></a>
<span class="sourceLineNo">946</span>    @Override<a name="line.946"></a>
<span class="sourceLineNo">947</span>    public boolean getFastFailValidation() {<a name="line.947"></a>
<span class="sourceLineNo">948</span>        return fastFailValidation;<a name="line.948"></a>
<span class="sourceLineNo">949</span>    }<a name="line.949"></a>
<span class="sourceLineNo">950</span><a name="line.950"></a>
<span class="sourceLineNo">951</span>    /**<a name="line.951"></a>
<span class="sourceLineNo">952</span>     * Returns the initial size of the connection pool.<a name="line.952"></a>
<span class="sourceLineNo">953</span>     *<a name="line.953"></a>
<span class="sourceLineNo">954</span>     * @return the number of connections created when the pool is initialized<a name="line.954"></a>
<span class="sourceLineNo">955</span>     */<a name="line.955"></a>
<span class="sourceLineNo">956</span>    @Override<a name="line.956"></a>
<span class="sourceLineNo">957</span>    public synchronized int getInitialSize() {<a name="line.957"></a>
<span class="sourceLineNo">958</span>        return this.initialSize;<a name="line.958"></a>
<span class="sourceLineNo">959</span>    }<a name="line.959"></a>
<span class="sourceLineNo">960</span><a name="line.960"></a>
<span class="sourceLineNo">961</span>    /**<a name="line.961"></a>
<span class="sourceLineNo">962</span>     * Returns the JMX name that has been requested for this DataSource. If the requested name is not valid, an<a name="line.962"></a>
<span class="sourceLineNo">963</span>     * alternative may be chosen.<a name="line.963"></a>
<span class="sourceLineNo">964</span>     *<a name="line.964"></a>
<span class="sourceLineNo">965</span>     * @return The JMX name that has been requested for this DataSource.<a name="line.965"></a>
<span class="sourceLineNo">966</span>     */<a name="line.966"></a>
<span class="sourceLineNo">967</span>    public String getJmxName() {<a name="line.967"></a>
<span class="sourceLineNo">968</span>        return jmxName;<a name="line.968"></a>
<span class="sourceLineNo">969</span>    }<a name="line.969"></a>
<span class="sourceLineNo">970</span><a name="line.970"></a>
<span class="sourceLineNo">971</span>    /**<a name="line.971"></a>
<span class="sourceLineNo">972</span>     * Returns the LIFO property.<a name="line.972"></a>
<span class="sourceLineNo">973</span>     *<a name="line.973"></a>
<span class="sourceLineNo">974</span>     * @return true if connection pool behaves as a LIFO queue.<a name="line.974"></a>
<span class="sourceLineNo">975</span>     */<a name="line.975"></a>
<span class="sourceLineNo">976</span>    @Override<a name="line.976"></a>
<span class="sourceLineNo">977</span>    public synchronized boolean getLifo() {<a name="line.977"></a>
<span class="sourceLineNo">978</span>        return this.lifo;<a name="line.978"></a>
<span class="sourceLineNo">979</span>    }<a name="line.979"></a>
<span class="sourceLineNo">980</span><a name="line.980"></a>
<span class="sourceLineNo">981</span>    /**<a name="line.981"></a>
<span class="sourceLineNo">982</span>     * &lt;p&gt;<a name="line.982"></a>
<span class="sourceLineNo">983</span>     * Flag to log stack traces for application code which abandoned a Statement or Connection.<a name="line.983"></a>
<span class="sourceLineNo">984</span>     * &lt;/p&gt;<a name="line.984"></a>
<span class="sourceLineNo">985</span>     * &lt;p&gt;<a name="line.985"></a>
<span class="sourceLineNo">986</span>     * Defaults to false.<a name="line.986"></a>
<span class="sourceLineNo">987</span>     * &lt;/p&gt;<a name="line.987"></a>
<span class="sourceLineNo">988</span>     * &lt;p&gt;<a name="line.988"></a>
<span class="sourceLineNo">989</span>     * Logging of abandoned Statements and Connections adds overhead for every Connection open or new Statement because<a name="line.989"></a>
<span class="sourceLineNo">990</span>     * a stack trace has to be generated.<a name="line.990"></a>
<span class="sourceLineNo">991</span>     * &lt;/p&gt;<a name="line.991"></a>
<span class="sourceLineNo">992</span>     */<a name="line.992"></a>
<span class="sourceLineNo">993</span>    @Override<a name="line.993"></a>
<span class="sourceLineNo">994</span>    public boolean getLogAbandoned() {<a name="line.994"></a>
<span class="sourceLineNo">995</span>        return abandonedConfig != null &amp;&amp; abandonedConfig.getLogAbandoned();<a name="line.995"></a>
<span class="sourceLineNo">996</span>    }<a name="line.996"></a>
<span class="sourceLineNo">997</span><a name="line.997"></a>
<span class="sourceLineNo">998</span>    /**<a name="line.998"></a>
<span class="sourceLineNo">999</span>     * When {@link #getMaxConnLifetimeMillis()} is set to limit connection lifetime, this property determines whether or<a name="line.999"></a>
<span class="sourceLineNo">1000</span>     * not log messages are generated when the pool closes connections due to maximum lifetime exceeded.<a name="line.1000"></a>
<span class="sourceLineNo">1001</span>     *<a name="line.1001"></a>
<span class="sourceLineNo">1002</span>     * @since 2.1<a name="line.1002"></a>
<span class="sourceLineNo">1003</span>     */<a name="line.1003"></a>
<span class="sourceLineNo">1004</span>    @Override<a name="line.1004"></a>
<span class="sourceLineNo">1005</span>    public boolean getLogExpiredConnections() {<a name="line.1005"></a>
<span class="sourceLineNo">1006</span>        return logExpiredConnections;<a name="line.1006"></a>
<span class="sourceLineNo">1007</span>    }<a name="line.1007"></a>
<span class="sourceLineNo">1008</span><a name="line.1008"></a>
<span class="sourceLineNo">1009</span>    /**<a name="line.1009"></a>
<span class="sourceLineNo">1010</span>     * &lt;strong&gt;BasicDataSource does NOT support this method.&lt;/strong&gt;<a name="line.1010"></a>
<span class="sourceLineNo">1011</span>     *<a name="line.1011"></a>
<span class="sourceLineNo">1012</span>     * &lt;p&gt;<a name="line.1012"></a>
<span class="sourceLineNo">1013</span>     * Returns the login timeout (in seconds) for connecting to the database.<a name="line.1013"></a>
<span class="sourceLineNo">1014</span>     * &lt;/p&gt;<a name="line.1014"></a>
<span class="sourceLineNo">1015</span>     * &lt;p&gt;<a name="line.1015"></a>
<span class="sourceLineNo">1016</span>     * Calls {@link #createDataSource()}, so has the side effect of initializing the connection pool.<a name="line.1016"></a>
<span class="sourceLineNo">1017</span>     * &lt;/p&gt;<a name="line.1017"></a>
<span class="sourceLineNo">1018</span>     *<a name="line.1018"></a>
<span class="sourceLineNo">1019</span>     * @throws SQLException                  if a database access error occurs<a name="line.1019"></a>
<span class="sourceLineNo">1020</span>     * @throws UnsupportedOperationException If the DataSource implementation does not support the login timeout<a name="line.1020"></a>
<span class="sourceLineNo">1021</span>     *                                       feature.<a name="line.1021"></a>
<span class="sourceLineNo">1022</span>     * @return login timeout in seconds<a name="line.1022"></a>
<span class="sourceLineNo">1023</span>     */<a name="line.1023"></a>
<span class="sourceLineNo">1024</span>    @Override<a name="line.1024"></a>
<span class="sourceLineNo">1025</span>    public int getLoginTimeout() throws SQLException {<a name="line.1025"></a>
<span class="sourceLineNo">1026</span>        // This method isn't supported by the PoolingDataSource returned by the createDataSource<a name="line.1026"></a>
<span class="sourceLineNo">1027</span>        throw new UnsupportedOperationException("Not supported by BasicDataSource");<a name="line.1027"></a>
<span class="sourceLineNo">1028</span>    }<a name="line.1028"></a>
<span class="sourceLineNo">1029</span><a name="line.1029"></a>
<span class="sourceLineNo">1030</span>    /**<a name="line.1030"></a>
<span class="sourceLineNo">1031</span>     * &lt;p&gt;<a name="line.1031"></a>
<span class="sourceLineNo">1032</span>     * Returns the log writer being used by this data source.<a name="line.1032"></a>
<span class="sourceLineNo">1033</span>     * &lt;/p&gt;<a name="line.1033"></a>
<span class="sourceLineNo">1034</span>     * &lt;p&gt;<a name="line.1034"></a>
<span class="sourceLineNo">1035</span>     * Calls {@link #createDataSource()}, so has the side effect of initializing the connection pool.<a name="line.1035"></a>
<span class="sourceLineNo">1036</span>     * &lt;/p&gt;<a name="line.1036"></a>
<span class="sourceLineNo">1037</span>     *<a name="line.1037"></a>
<span class="sourceLineNo">1038</span>     * @throws SQLException if a database access error occurs<a name="line.1038"></a>
<span class="sourceLineNo">1039</span>     * @return log writer in use<a name="line.1039"></a>
<span class="sourceLineNo">1040</span>     */<a name="line.1040"></a>
<span class="sourceLineNo">1041</span>    @Override<a name="line.1041"></a>
<span class="sourceLineNo">1042</span>    public PrintWriter getLogWriter() throws SQLException {<a name="line.1042"></a>
<span class="sourceLineNo">1043</span>        return createDataSource().getLogWriter();<a name="line.1043"></a>
<span class="sourceLineNo">1044</span>    }<a name="line.1044"></a>
<span class="sourceLineNo">1045</span><a name="line.1045"></a>
<span class="sourceLineNo">1046</span>    /**<a name="line.1046"></a>
<span class="sourceLineNo">1047</span>     * Returns the maximum permitted lifetime of a connection in milliseconds. A value of zero or less indicates an<a name="line.1047"></a>
<span class="sourceLineNo">1048</span>     * infinite lifetime.<a name="line.1048"></a>
<span class="sourceLineNo">1049</span>     */<a name="line.1049"></a>
<span class="sourceLineNo">1050</span>    @Override<a name="line.1050"></a>
<span class="sourceLineNo">1051</span>    public long getMaxConnLifetimeMillis() {<a name="line.1051"></a>
<span class="sourceLineNo">1052</span>        return maxConnLifetimeMillis;<a name="line.1052"></a>
<span class="sourceLineNo">1053</span>    }<a name="line.1053"></a>
<span class="sourceLineNo">1054</span><a name="line.1054"></a>
<span class="sourceLineNo">1055</span>    /**<a name="line.1055"></a>
<span class="sourceLineNo">1056</span>     * &lt;p&gt;<a name="line.1056"></a>
<span class="sourceLineNo">1057</span>     * Returns the maximum number of connections that can remain idle in the pool. Excess idle connections are destroyed<a name="line.1057"></a>
<span class="sourceLineNo">1058</span>     * on return to the pool.<a name="line.1058"></a>
<span class="sourceLineNo">1059</span>     * &lt;/p&gt;<a name="line.1059"></a>
<span class="sourceLineNo">1060</span>     * &lt;p&gt;<a name="line.1060"></a>
<span class="sourceLineNo">1061</span>     * A negative value indicates that there is no limit<a name="line.1061"></a>
<span class="sourceLineNo">1062</span>     * &lt;/p&gt;<a name="line.1062"></a>
<span class="sourceLineNo">1063</span>     *<a name="line.1063"></a>
<span class="sourceLineNo">1064</span>     * @return the maximum number of idle connections<a name="line.1064"></a>
<span class="sourceLineNo">1065</span>     */<a name="line.1065"></a>
<span class="sourceLineNo">1066</span>    @Override<a name="line.1066"></a>
<span class="sourceLineNo">1067</span>    public synchronized int getMaxIdle() {<a name="line.1067"></a>
<span class="sourceLineNo">1068</span>        return this.maxIdle;<a name="line.1068"></a>
<span class="sourceLineNo">1069</span>    }<a name="line.1069"></a>
<span class="sourceLineNo">1070</span><a name="line.1070"></a>
<span class="sourceLineNo">1071</span>    /**<a name="line.1071"></a>
<span class="sourceLineNo">1072</span>     * Gets the value of the &lt;code&gt;maxOpenPreparedStatements&lt;/code&gt; property.<a name="line.1072"></a>
<span class="sourceLineNo">1073</span>     *<a name="line.1073"></a>
<span class="sourceLineNo">1074</span>     * @return the maximum number of open statements<a name="line.1074"></a>
<span class="sourceLineNo">1075</span>     */<a name="line.1075"></a>
<span class="sourceLineNo">1076</span>    @Override<a name="line.1076"></a>
<span class="sourceLineNo">1077</span>    public synchronized int getMaxOpenPreparedStatements() {<a name="line.1077"></a>
<span class="sourceLineNo">1078</span>        return this.maxOpenPreparedStatements;<a name="line.1078"></a>
<span class="sourceLineNo">1079</span>    }<a name="line.1079"></a>
<span class="sourceLineNo">1080</span><a name="line.1080"></a>
<span class="sourceLineNo">1081</span>    /**<a name="line.1081"></a>
<span class="sourceLineNo">1082</span>     * &lt;p&gt;<a name="line.1082"></a>
<span class="sourceLineNo">1083</span>     * Returns the maximum number of active connections that can be allocated at the same time.<a name="line.1083"></a>
<span class="sourceLineNo">1084</span>     * &lt;/p&gt;<a name="line.1084"></a>
<span class="sourceLineNo">1085</span>     * &lt;p&gt;<a name="line.1085"></a>
<span class="sourceLineNo">1086</span>     * A negative number means that there is no limit.<a name="line.1086"></a>
<span class="sourceLineNo">1087</span>     * &lt;/p&gt;<a name="line.1087"></a>
<span class="sourceLineNo">1088</span>     *<a name="line.1088"></a>
<span class="sourceLineNo">1089</span>     * @return the maximum number of active connections<a name="line.1089"></a>
<span class="sourceLineNo">1090</span>     */<a name="line.1090"></a>
<span class="sourceLineNo">1091</span>    @Override<a name="line.1091"></a>
<span class="sourceLineNo">1092</span>    public synchronized int getMaxTotal() {<a name="line.1092"></a>
<span class="sourceLineNo">1093</span>        return this.maxTotal;<a name="line.1093"></a>
<span class="sourceLineNo">1094</span>    }<a name="line.1094"></a>
<span class="sourceLineNo">1095</span><a name="line.1095"></a>
<span class="sourceLineNo">1096</span>    /**<a name="line.1096"></a>
<span class="sourceLineNo">1097</span>     * Returns the maximum number of milliseconds that the pool will wait for a connection to be returned before<a name="line.1097"></a>
<span class="sourceLineNo">1098</span>     * throwing an exception. A value less than or equal to zero means the pool is set to wait indefinitely.<a name="line.1098"></a>
<span class="sourceLineNo">1099</span>     *<a name="line.1099"></a>
<span class="sourceLineNo">1100</span>     * @return the maxWaitMillis property value<a name="line.1100"></a>
<span class="sourceLineNo">1101</span>     */<a name="line.1101"></a>
<span class="sourceLineNo">1102</span>    @Override<a name="line.1102"></a>
<span class="sourceLineNo">1103</span>    public synchronized long getMaxWaitMillis() {<a name="line.1103"></a>
<span class="sourceLineNo">1104</span>        return this.maxWaitMillis;<a name="line.1104"></a>
<span class="sourceLineNo">1105</span>    }<a name="line.1105"></a>
<span class="sourceLineNo">1106</span><a name="line.1106"></a>
<span class="sourceLineNo">1107</span>    /**<a name="line.1107"></a>
<span class="sourceLineNo">1108</span>     * Returns the {@link #minEvictableIdleTimeMillis} property.<a name="line.1108"></a>
<span class="sourceLineNo">1109</span>     *<a name="line.1109"></a>
<span class="sourceLineNo">1110</span>     * @return the value of the {@link #minEvictableIdleTimeMillis} property<a name="line.1110"></a>
<span class="sourceLineNo">1111</span>     * @see #minEvictableIdleTimeMillis<a name="line.1111"></a>
<span class="sourceLineNo">1112</span>     */<a name="line.1112"></a>
<span class="sourceLineNo">1113</span>    @Override<a name="line.1113"></a>
<span class="sourceLineNo">1114</span>    public synchronized long getMinEvictableIdleTimeMillis() {<a name="line.1114"></a>
<span class="sourceLineNo">1115</span>        return this.minEvictableIdleTimeMillis;<a name="line.1115"></a>
<span class="sourceLineNo">1116</span>    }<a name="line.1116"></a>
<span class="sourceLineNo">1117</span><a name="line.1117"></a>
<span class="sourceLineNo">1118</span>    /**<a name="line.1118"></a>
<span class="sourceLineNo">1119</span>     * Returns the minimum number of idle connections in the pool. The pool attempts to ensure that minIdle connections<a name="line.1119"></a>
<span class="sourceLineNo">1120</span>     * are available when the idle object evictor runs. The value of this property has no effect unless<a name="line.1120"></a>
<span class="sourceLineNo">1121</span>     * {@link #timeBetweenEvictionRunsMillis} has a positive value.<a name="line.1121"></a>
<span class="sourceLineNo">1122</span>     *<a name="line.1122"></a>
<span class="sourceLineNo">1123</span>     * @return the minimum number of idle connections<a name="line.1123"></a>
<span class="sourceLineNo">1124</span>     * @see GenericObjectPool#getMinIdle()<a name="line.1124"></a>
<span class="sourceLineNo">1125</span>     */<a name="line.1125"></a>
<span class="sourceLineNo">1126</span>    @Override<a name="line.1126"></a>
<span class="sourceLineNo">1127</span>    public synchronized int getMinIdle() {<a name="line.1127"></a>
<span class="sourceLineNo">1128</span>        return this.minIdle;<a name="line.1128"></a>
<span class="sourceLineNo">1129</span>    }<a name="line.1129"></a>
<span class="sourceLineNo">1130</span><a name="line.1130"></a>
<span class="sourceLineNo">1131</span>    /**<a name="line.1131"></a>
<span class="sourceLineNo">1132</span>     * [Read Only] The current number of active connections that have been allocated from this data source.<a name="line.1132"></a>
<span class="sourceLineNo">1133</span>     *<a name="line.1133"></a>
<span class="sourceLineNo">1134</span>     * @return the current number of active connections<a name="line.1134"></a>
<span class="sourceLineNo">1135</span>     */<a name="line.1135"></a>
<span class="sourceLineNo">1136</span>    @Override<a name="line.1136"></a>
<span class="sourceLineNo">1137</span>    public int getNumActive() {<a name="line.1137"></a>
<span class="sourceLineNo">1138</span>        // Copy reference to avoid NPE if close happens after null check<a name="line.1138"></a>
<span class="sourceLineNo">1139</span>        final GenericObjectPool&lt;PoolableConnection&gt; pool = connectionPool;<a name="line.1139"></a>
<span class="sourceLineNo">1140</span>        return pool == null ? 0 : pool.getNumActive();<a name="line.1140"></a>
<span class="sourceLineNo">1141</span>    }<a name="line.1141"></a>
<span class="sourceLineNo">1142</span><a name="line.1142"></a>
<span class="sourceLineNo">1143</span>    /**<a name="line.1143"></a>
<span class="sourceLineNo">1144</span>     * [Read Only] The current number of idle connections that are waiting to be allocated from this data source.<a name="line.1144"></a>
<span class="sourceLineNo">1145</span>     *<a name="line.1145"></a>
<span class="sourceLineNo">1146</span>     * @return the current number of idle connections<a name="line.1146"></a>
<span class="sourceLineNo">1147</span>     */<a name="line.1147"></a>
<span class="sourceLineNo">1148</span>    @Override<a name="line.1148"></a>
<span class="sourceLineNo">1149</span>    public int getNumIdle() {<a name="line.1149"></a>
<span class="sourceLineNo">1150</span>        // Copy reference to avoid NPE if close happens after null check<a name="line.1150"></a>
<span class="sourceLineNo">1151</span>        final GenericObjectPool&lt;PoolableConnection&gt; pool = connectionPool;<a name="line.1151"></a>
<span class="sourceLineNo">1152</span>        return pool == null ? 0 : pool.getNumIdle();<a name="line.1152"></a>
<span class="sourceLineNo">1153</span>    }<a name="line.1153"></a>
<span class="sourceLineNo">1154</span><a name="line.1154"></a>
<span class="sourceLineNo">1155</span>    /**<a name="line.1155"></a>
<span class="sourceLineNo">1156</span>     * Returns the value of the {@link #numTestsPerEvictionRun} property.<a name="line.1156"></a>
<span class="sourceLineNo">1157</span>     *<a name="line.1157"></a>
<span class="sourceLineNo">1158</span>     * @return the number of objects to examine during idle object evictor runs<a name="line.1158"></a>
<span class="sourceLineNo">1159</span>     * @see #numTestsPerEvictionRun<a name="line.1159"></a>
<span class="sourceLineNo">1160</span>     */<a name="line.1160"></a>
<span class="sourceLineNo">1161</span>    @Override<a name="line.1161"></a>
<span class="sourceLineNo">1162</span>    public synchronized int getNumTestsPerEvictionRun() {<a name="line.1162"></a>
<span class="sourceLineNo">1163</span>        return this.numTestsPerEvictionRun;<a name="line.1163"></a>
<span class="sourceLineNo">1164</span>    }<a name="line.1164"></a>
<span class="sourceLineNo">1165</span><a name="line.1165"></a>
<span class="sourceLineNo">1166</span>    @Override<a name="line.1166"></a>
<span class="sourceLineNo">1167</span>    public Logger getParentLogger() throws SQLFeatureNotSupportedException {<a name="line.1167"></a>
<span class="sourceLineNo">1168</span>        throw new SQLFeatureNotSupportedException();<a name="line.1168"></a>
<span class="sourceLineNo">1169</span>    }<a name="line.1169"></a>
<span class="sourceLineNo">1170</span><a name="line.1170"></a>
<span class="sourceLineNo">1171</span>    /**<a name="line.1171"></a>
<span class="sourceLineNo">1172</span>     * Returns the password passed to the JDBC driver to establish connections.<a name="line.1172"></a>
<span class="sourceLineNo">1173</span>     *<a name="line.1173"></a>
<span class="sourceLineNo">1174</span>     * @return the connection password<a name="line.1174"></a>
<span class="sourceLineNo">1175</span>     */<a name="line.1175"></a>
<span class="sourceLineNo">1176</span>    @Override<a name="line.1176"></a>
<span class="sourceLineNo">1177</span>    public String getPassword() {<a name="line.1177"></a>
<span class="sourceLineNo">1178</span>        return this.password;<a name="line.1178"></a>
<span class="sourceLineNo">1179</span>    }<a name="line.1179"></a>
<span class="sourceLineNo">1180</span><a name="line.1180"></a>
<span class="sourceLineNo">1181</span>    protected ObjectName getRegisteredJmxName() {<a name="line.1181"></a>
<span class="sourceLineNo">1182</span>        return ObjectNameWrapper.unwrap(registeredJmxObjectName);<a name="line.1182"></a>
<span class="sourceLineNo">1183</span>    }<a name="line.1183"></a>
<span class="sourceLineNo">1184</span><a name="line.1184"></a>
<span class="sourceLineNo">1185</span>    /**<a name="line.1185"></a>
<span class="sourceLineNo">1186</span>     * &lt;p&gt;<a name="line.1186"></a>
<span class="sourceLineNo">1187</span>     * Flag to remove abandoned connections if they exceed the removeAbandonedTimeout when borrowObject is invoked.<a name="line.1187"></a>
<span class="sourceLineNo">1188</span>     * &lt;/p&gt;<a name="line.1188"></a>
<span class="sourceLineNo">1189</span>     * &lt;p&gt;<a name="line.1189"></a>
<span class="sourceLineNo">1190</span>     * The default value is false.<a name="line.1190"></a>
<span class="sourceLineNo">1191</span>     * &lt;/p&gt;<a name="line.1191"></a>
<span class="sourceLineNo">1192</span>     * &lt;p&gt;<a name="line.1192"></a>
<span class="sourceLineNo">1193</span>     * If set to true a connection is considered abandoned and eligible for removal if it has not been used for more<a name="line.1193"></a>
<span class="sourceLineNo">1194</span>     * than {@link #getRemoveAbandonedTimeout() removeAbandonedTimeout} seconds.<a name="line.1194"></a>
<span class="sourceLineNo">1195</span>     * &lt;/p&gt;<a name="line.1195"></a>
<span class="sourceLineNo">1196</span>     * &lt;p&gt;<a name="line.1196"></a>
<span class="sourceLineNo">1197</span>     * Abandoned connections are identified and removed when {@link #getConnection()} is invoked and all of the<a name="line.1197"></a>
<span class="sourceLineNo">1198</span>     * following conditions hold:<a name="line.1198"></a>
<span class="sourceLineNo">1199</span>     * &lt;/p&gt;<a name="line.1199"></a>
<span class="sourceLineNo">1200</span>     * &lt;ul&gt;<a name="line.1200"></a>
<span class="sourceLineNo">1201</span>     * &lt;li&gt;{@link #getRemoveAbandonedOnBorrow()}&lt;/li&gt;<a name="line.1201"></a>
<span class="sourceLineNo">1202</span>     * &lt;li&gt;{@link #getNumActive()} &amp;gt; {@link #getMaxTotal()} - 3&lt;/li&gt;<a name="line.1202"></a>
<span class="sourceLineNo">1203</span>     * &lt;li&gt;{@link #getNumIdle()} &amp;lt; 2&lt;/li&gt;<a name="line.1203"></a>
<span class="sourceLineNo">1204</span>     * &lt;/ul&gt;<a name="line.1204"></a>
<span class="sourceLineNo">1205</span>     *<a name="line.1205"></a>
<span class="sourceLineNo">1206</span>     * @see #getRemoveAbandonedTimeout()<a name="line.1206"></a>
<span class="sourceLineNo">1207</span>     */<a name="line.1207"></a>
<span class="sourceLineNo">1208</span>    @Override<a name="line.1208"></a>
<span class="sourceLineNo">1209</span>    public boolean getRemoveAbandonedOnBorrow() {<a name="line.1209"></a>
<span class="sourceLineNo">1210</span>        return abandonedConfig != null &amp;&amp; abandonedConfig.getRemoveAbandonedOnBorrow();<a name="line.1210"></a>
<span class="sourceLineNo">1211</span>    }<a name="line.1211"></a>
<span class="sourceLineNo">1212</span><a name="line.1212"></a>
<span class="sourceLineNo">1213</span>    /**<a name="line.1213"></a>
<span class="sourceLineNo">1214</span>     * &lt;p&gt;<a name="line.1214"></a>
<span class="sourceLineNo">1215</span>     * Flag to remove abandoned connections if they exceed the removeAbandonedTimeout during pool maintenance.<a name="line.1215"></a>
<span class="sourceLineNo">1216</span>     * &lt;/p&gt;<a name="line.1216"></a>
<span class="sourceLineNo">1217</span>     *<a name="line.1217"></a>
<span class="sourceLineNo">1218</span>     * &lt;p&gt;<a name="line.1218"></a>
<span class="sourceLineNo">1219</span>     * The default value is false.<a name="line.1219"></a>
<span class="sourceLineNo">1220</span>     * &lt;/p&gt;<a name="line.1220"></a>
<span class="sourceLineNo">1221</span>     *<a name="line.1221"></a>
<span class="sourceLineNo">1222</span>     * &lt;p&gt;<a name="line.1222"></a>
<span class="sourceLineNo">1223</span>     * If set to true a connection is considered abandoned and eligible for removal if it has not been used for more<a name="line.1223"></a>
<span class="sourceLineNo">1224</span>     * than {@link #getRemoveAbandonedTimeout() removeAbandonedTimeout} seconds.<a name="line.1224"></a>
<span class="sourceLineNo">1225</span>     * &lt;/p&gt;<a name="line.1225"></a>
<span class="sourceLineNo">1226</span>     *<a name="line.1226"></a>
<span class="sourceLineNo">1227</span>     * @see #getRemoveAbandonedTimeout()<a name="line.1227"></a>
<span class="sourceLineNo">1228</span>     */<a name="line.1228"></a>
<span class="sourceLineNo">1229</span>    @Override<a name="line.1229"></a>
<span class="sourceLineNo">1230</span>    public boolean getRemoveAbandonedOnMaintenance() {<a name="line.1230"></a>
<span class="sourceLineNo">1231</span>        return abandonedConfig != null &amp;&amp; abandonedConfig.getRemoveAbandonedOnMaintenance();<a name="line.1231"></a>
<span class="sourceLineNo">1232</span>    }<a name="line.1232"></a>
<span class="sourceLineNo">1233</span><a name="line.1233"></a>
<span class="sourceLineNo">1234</span>    /**<a name="line.1234"></a>
<span class="sourceLineNo">1235</span>     * &lt;p&gt;<a name="line.1235"></a>
<span class="sourceLineNo">1236</span>     * Timeout in seconds before an abandoned connection can be removed.<a name="line.1236"></a>
<span class="sourceLineNo">1237</span>     * &lt;/p&gt;<a name="line.1237"></a>
<span class="sourceLineNo">1238</span>     * &lt;p&gt;<a name="line.1238"></a>
<span class="sourceLineNo">1239</span>     * Creating a Statement, PreparedStatement or CallableStatement or using one of these to execute a query (using one<a name="line.1239"></a>
<span class="sourceLineNo">1240</span>     * of the execute methods) resets the lastUsed property of the parent connection.<a name="line.1240"></a>
<span class="sourceLineNo">1241</span>     * &lt;/p&gt;<a name="line.1241"></a>
<span class="sourceLineNo">1242</span>     * &lt;p&gt;<a name="line.1242"></a>
<span class="sourceLineNo">1243</span>     * Abandoned connection cleanup happens when:<a name="line.1243"></a>
<span class="sourceLineNo">1244</span>     * &lt;/p&gt;<a name="line.1244"></a>
<span class="sourceLineNo">1245</span>     * &lt;ul&gt;<a name="line.1245"></a>
<span class="sourceLineNo">1246</span>     * &lt;li&gt;{@link #getRemoveAbandonedOnBorrow()} or {@link #getRemoveAbandonedOnMaintenance()} = true&lt;/li&gt;<a name="line.1246"></a>
<span class="sourceLineNo">1247</span>     * &lt;li&gt;{@link #getNumIdle() numIdle} &amp;lt; 2&lt;/li&gt;<a name="line.1247"></a>
<span class="sourceLineNo">1248</span>     * &lt;li&gt;{@link #getNumActive() numActive} &amp;gt; {@link #getMaxTotal() maxTotal} - 3&lt;/li&gt;<a name="line.1248"></a>
<span class="sourceLineNo">1249</span>     * &lt;/ul&gt;<a name="line.1249"></a>
<span class="sourceLineNo">1250</span>     * &lt;p&gt;<a name="line.1250"></a>
<span class="sourceLineNo">1251</span>     * The default value is 300 seconds.<a name="line.1251"></a>
<span class="sourceLineNo">1252</span>     * &lt;/p&gt;<a name="line.1252"></a>
<span class="sourceLineNo">1253</span>     */<a name="line.1253"></a>
<span class="sourceLineNo">1254</span>    @Override<a name="line.1254"></a>
<span class="sourceLineNo">1255</span>    public int getRemoveAbandonedTimeout() {<a name="line.1255"></a>
<span class="sourceLineNo">1256</span>        return abandonedConfig == null ? 300 : abandonedConfig.getRemoveAbandonedTimeout();<a name="line.1256"></a>
<span class="sourceLineNo">1257</span>    }<a name="line.1257"></a>
<span class="sourceLineNo">1258</span><a name="line.1258"></a>
<span class="sourceLineNo">1259</span>    /**<a name="line.1259"></a>
<span class="sourceLineNo">1260</span>     * Gets the current value of the flag that controls whether a connection will be rolled back when it is returned to<a name="line.1260"></a>
<span class="sourceLineNo">1261</span>     * the pool if auto commit is not enabled and the connection is not read only.<a name="line.1261"></a>
<span class="sourceLineNo">1262</span>     *<a name="line.1262"></a>
<span class="sourceLineNo">1263</span>     * @return whether a connection will be rolled back when it is returned to the pool.<a name="line.1263"></a>
<span class="sourceLineNo">1264</span>     */<a name="line.1264"></a>
<span class="sourceLineNo">1265</span>    public boolean getRollbackOnReturn() {<a name="line.1265"></a>
<span class="sourceLineNo">1266</span>        return rollbackOnReturn;<a name="line.1266"></a>
<span class="sourceLineNo">1267</span>    }<a name="line.1267"></a>
<span class="sourceLineNo">1268</span><a name="line.1268"></a>
<span class="sourceLineNo">1269</span>    /**<a name="line.1269"></a>
<span class="sourceLineNo">1270</span>     * &lt;p&gt;<a name="line.1270"></a>
<span class="sourceLineNo">1271</span>     * Returns the minimum amount of time a connection may sit idle in the pool before it is eligible for eviction by<a name="line.1271"></a>
<span class="sourceLineNo">1272</span>     * the idle object evictor, with the extra condition that at least "minIdle" connections remain in the pool.<a name="line.1272"></a>
<span class="sourceLineNo">1273</span>     * &lt;/p&gt;<a name="line.1273"></a>
<span class="sourceLineNo">1274</span>     *<a name="line.1274"></a>
<span class="sourceLineNo">1275</span>     * &lt;p&gt;<a name="line.1275"></a>
<span class="sourceLineNo">1276</span>     * When {@link #getMinEvictableIdleTimeMillis() minEvictableIdleTimeMillis} is set to a positive value,<a name="line.1276"></a>
<span class="sourceLineNo">1277</span>     * minEvictableIdleTimeMillis is examined first by the idle connection evictor - i.e. when idle connections are<a name="line.1277"></a>
<span class="sourceLineNo">1278</span>     * visited by the evictor, idle time is first compared against {@code minEvictableIdleTimeMillis} (without<a name="line.1278"></a>
<span class="sourceLineNo">1279</span>     * considering the number of idle connections in the pool) and then against {@code softMinEvictableIdleTimeMillis},<a name="line.1279"></a>
<span class="sourceLineNo">1280</span>     * including the {@code minIdle}, constraint.<a name="line.1280"></a>
<span class="sourceLineNo">1281</span>     * &lt;/p&gt;<a name="line.1281"></a>
<span class="sourceLineNo">1282</span>     *<a name="line.1282"></a>
<span class="sourceLineNo">1283</span>     * @return minimum amount of time a connection may sit idle in the pool before it is eligible for eviction, assuming<a name="line.1283"></a>
<span class="sourceLineNo">1284</span>     *         there are minIdle idle connections in the pool<a name="line.1284"></a>
<span class="sourceLineNo">1285</span>     */<a name="line.1285"></a>
<span class="sourceLineNo">1286</span>    @Override<a name="line.1286"></a>
<span class="sourceLineNo">1287</span>    public synchronized long getSoftMinEvictableIdleTimeMillis() {<a name="line.1287"></a>
<span class="sourceLineNo">1288</span>        return softMinEvictableIdleTimeMillis;<a name="line.1288"></a>
<span class="sourceLineNo">1289</span>    }<a name="line.1289"></a>
<span class="sourceLineNo">1290</span><a name="line.1290"></a>
<span class="sourceLineNo">1291</span>    /**<a name="line.1291"></a>
<span class="sourceLineNo">1292</span>     * Returns the {@link #testOnBorrow} property.<a name="line.1292"></a>
<span class="sourceLineNo">1293</span>     *<a name="line.1293"></a>
<span class="sourceLineNo">1294</span>     * @return true if objects are validated before being borrowed from the pool<a name="line.1294"></a>
<span class="sourceLineNo">1295</span>     *<a name="line.1295"></a>
<span class="sourceLineNo">1296</span>     * @see #testOnBorrow<a name="line.1296"></a>
<span class="sourceLineNo">1297</span>     */<a name="line.1297"></a>
<span class="sourceLineNo">1298</span>    @Override<a name="line.1298"></a>
<span class="sourceLineNo">1299</span>    public synchronized boolean getTestOnBorrow() {<a name="line.1299"></a>
<span class="sourceLineNo">1300</span>        return this.testOnBorrow;<a name="line.1300"></a>
<span class="sourceLineNo">1301</span>    }<a name="line.1301"></a>
<span class="sourceLineNo">1302</span><a name="line.1302"></a>
<span class="sourceLineNo">1303</span>    /**<a name="line.1303"></a>
<span class="sourceLineNo">1304</span>     * Returns the {@link #testOnCreate} property.<a name="line.1304"></a>
<span class="sourceLineNo">1305</span>     *<a name="line.1305"></a>
<span class="sourceLineNo">1306</span>     * @return true if objects are validated immediately after they are created by the pool<a name="line.1306"></a>
<span class="sourceLineNo">1307</span>     * @see #testOnCreate<a name="line.1307"></a>
<span class="sourceLineNo">1308</span>     */<a name="line.1308"></a>
<span class="sourceLineNo">1309</span>    @Override<a name="line.1309"></a>
<span class="sourceLineNo">1310</span>    public synchronized boolean getTestOnCreate() {<a name="line.1310"></a>
<span class="sourceLineNo">1311</span>        return this.testOnCreate;<a name="line.1311"></a>
<span class="sourceLineNo">1312</span>    }<a name="line.1312"></a>
<span class="sourceLineNo">1313</span><a name="line.1313"></a>
<span class="sourceLineNo">1314</span>    /**<a name="line.1314"></a>
<span class="sourceLineNo">1315</span>     * Returns the value of the {@link #testOnReturn} property.<a name="line.1315"></a>
<span class="sourceLineNo">1316</span>     *<a name="line.1316"></a>
<span class="sourceLineNo">1317</span>     * @return true if objects are validated before being returned to the pool<a name="line.1317"></a>
<span class="sourceLineNo">1318</span>     * @see #testOnReturn<a name="line.1318"></a>
<span class="sourceLineNo">1319</span>     */<a name="line.1319"></a>
<span class="sourceLineNo">1320</span>    public synchronized boolean getTestOnReturn() {<a name="line.1320"></a>
<span class="sourceLineNo">1321</span>        return this.testOnReturn;<a name="line.1321"></a>
<span class="sourceLineNo">1322</span>    }<a name="line.1322"></a>
<span class="sourceLineNo">1323</span><a name="line.1323"></a>
<span class="sourceLineNo">1324</span>    /**<a name="line.1324"></a>
<span class="sourceLineNo">1325</span>     * Returns the value of the {@link #testWhileIdle} property.<a name="line.1325"></a>
<span class="sourceLineNo">1326</span>     *<a name="line.1326"></a>
<span class="sourceLineNo">1327</span>     * @return true if objects examined by the idle object evictor are validated<a name="line.1327"></a>
<span class="sourceLineNo">1328</span>     * @see #testWhileIdle<a name="line.1328"></a>
<span class="sourceLineNo">1329</span>     */<a name="line.1329"></a>
<span class="sourceLineNo">1330</span>    @Override<a name="line.1330"></a>
<span class="sourceLineNo">1331</span>    public synchronized boolean getTestWhileIdle() {<a name="line.1331"></a>
<span class="sourceLineNo">1332</span>        return this.testWhileIdle;<a name="line.1332"></a>
<span class="sourceLineNo">1333</span>    }<a name="line.1333"></a>
<span class="sourceLineNo">1334</span><a name="line.1334"></a>
<span class="sourceLineNo">1335</span>    /**<a name="line.1335"></a>
<span class="sourceLineNo">1336</span>     * Returns the value of the {@link #timeBetweenEvictionRunsMillis} property.<a name="line.1336"></a>
<span class="sourceLineNo">1337</span>     *<a name="line.1337"></a>
<span class="sourceLineNo">1338</span>     * @return the time (in milliseconds) between evictor runs<a name="line.1338"></a>
<span class="sourceLineNo">1339</span>     * @see #timeBetweenEvictionRunsMillis<a name="line.1339"></a>
<span class="sourceLineNo">1340</span>     */<a name="line.1340"></a>
<span class="sourceLineNo">1341</span>    @Override<a name="line.1341"></a>
<span class="sourceLineNo">1342</span>    public synchronized long getTimeBetweenEvictionRunsMillis() {<a name="line.1342"></a>
<span class="sourceLineNo">1343</span>        return this.timeBetweenEvictionRunsMillis;<a name="line.1343"></a>
<span class="sourceLineNo">1344</span>    }<a name="line.1344"></a>
<span class="sourceLineNo">1345</span><a name="line.1345"></a>
<span class="sourceLineNo">1346</span>    /**<a name="line.1346"></a>
<span class="sourceLineNo">1347</span>     * Returns the JDBC connection {@link #url} property.<a name="line.1347"></a>
<span class="sourceLineNo">1348</span>     *<a name="line.1348"></a>
<span class="sourceLineNo">1349</span>     * @return the {@link #url} passed to the JDBC driver to establish connections<a name="line.1349"></a>
<span class="sourceLineNo">1350</span>     */<a name="line.1350"></a>
<span class="sourceLineNo">1351</span>    @Override<a name="line.1351"></a>
<span class="sourceLineNo">1352</span>    public synchronized String getUrl() {<a name="line.1352"></a>
<span class="sourceLineNo">1353</span>        return this.url;<a name="line.1353"></a>
<span class="sourceLineNo">1354</span>    }<a name="line.1354"></a>
<span class="sourceLineNo">1355</span><a name="line.1355"></a>
<span class="sourceLineNo">1356</span>    /**<a name="line.1356"></a>
<span class="sourceLineNo">1357</span>     * Returns the JDBC connection {@link #userName} property.<a name="line.1357"></a>
<span class="sourceLineNo">1358</span>     *<a name="line.1358"></a>
<span class="sourceLineNo">1359</span>     * @return the {@link #userName} passed to the JDBC driver to establish connections<a name="line.1359"></a>
<span class="sourceLineNo">1360</span>     */<a name="line.1360"></a>
<span class="sourceLineNo">1361</span>    @Override<a name="line.1361"></a>
<span class="sourceLineNo">1362</span>    public String getUsername() {<a name="line.1362"></a>
<span class="sourceLineNo">1363</span>        return this.userName;<a name="line.1363"></a>
<span class="sourceLineNo">1364</span>    }<a name="line.1364"></a>
<span class="sourceLineNo">1365</span><a name="line.1365"></a>
<span class="sourceLineNo">1366</span>    /**<a name="line.1366"></a>
<span class="sourceLineNo">1367</span>     * Returns the validation query used to validate connections before returning them.<a name="line.1367"></a>
<span class="sourceLineNo">1368</span>     *<a name="line.1368"></a>
<span class="sourceLineNo">1369</span>     * @return the SQL validation query<a name="line.1369"></a>
<span class="sourceLineNo">1370</span>     * @see #validationQuery<a name="line.1370"></a>
<span class="sourceLineNo">1371</span>     */<a name="line.1371"></a>
<span class="sourceLineNo">1372</span>    @Override<a name="line.1372"></a>
<span class="sourceLineNo">1373</span>    public String getValidationQuery() {<a name="line.1373"></a>
<span class="sourceLineNo">1374</span>        return this.validationQuery;<a name="line.1374"></a>
<span class="sourceLineNo">1375</span>    }<a name="line.1375"></a>
<span class="sourceLineNo">1376</span><a name="line.1376"></a>
<span class="sourceLineNo">1377</span>    /**<a name="line.1377"></a>
<span class="sourceLineNo">1378</span>     * Returns the validation query timeout.<a name="line.1378"></a>
<span class="sourceLineNo">1379</span>     *<a name="line.1379"></a>
<span class="sourceLineNo">1380</span>     * @return the timeout in seconds before connection validation queries fail.<a name="line.1380"></a>
<span class="sourceLineNo">1381</span>     */<a name="line.1381"></a>
<span class="sourceLineNo">1382</span>    @Override<a name="line.1382"></a>
<span class="sourceLineNo">1383</span>    public int getValidationQueryTimeout() {<a name="line.1383"></a>
<span class="sourceLineNo">1384</span>        return validationQueryTimeoutSeconds;<a name="line.1384"></a>
<span class="sourceLineNo">1385</span>    }<a name="line.1385"></a>
<span class="sourceLineNo">1386</span><a name="line.1386"></a>
<span class="sourceLineNo">1387</span>    /**<a name="line.1387"></a>
<span class="sourceLineNo">1388</span>     * Manually invalidates a connection, effectively requesting the pool to try to close it, remove it from the pool<a name="line.1388"></a>
<span class="sourceLineNo">1389</span>     * and reclaim pool capacity.<a name="line.1389"></a>
<span class="sourceLineNo">1390</span>     *<a name="line.1390"></a>
<span class="sourceLineNo">1391</span>     * @param connection The Connection to invalidate.<a name="line.1391"></a>
<span class="sourceLineNo">1392</span>     *<a name="line.1392"></a>
<span class="sourceLineNo">1393</span>     * @throws IllegalStateException if invalidating the connection failed.<a name="line.1393"></a>
<span class="sourceLineNo">1394</span>     * @since 2.1<a name="line.1394"></a>
<span class="sourceLineNo">1395</span>     */<a name="line.1395"></a>
<span class="sourceLineNo">1396</span>    @SuppressWarnings("resource")<a name="line.1396"></a>
<span class="sourceLineNo">1397</span>    public void invalidateConnection(final Connection connection) throws IllegalStateException {<a name="line.1397"></a>
<span class="sourceLineNo">1398</span>        if (connection == null) {<a name="line.1398"></a>
<span class="sourceLineNo">1399</span>            return;<a name="line.1399"></a>
<span class="sourceLineNo">1400</span>        }<a name="line.1400"></a>
<span class="sourceLineNo">1401</span>        if (connectionPool == null) {<a name="line.1401"></a>
<span class="sourceLineNo">1402</span>            throw new IllegalStateException("Cannot invalidate connection: ConnectionPool is null.");<a name="line.1402"></a>
<span class="sourceLineNo">1403</span>        }<a name="line.1403"></a>
<span class="sourceLineNo">1404</span><a name="line.1404"></a>
<span class="sourceLineNo">1405</span>        final PoolableConnection poolableConnection;<a name="line.1405"></a>
<span class="sourceLineNo">1406</span>        try {<a name="line.1406"></a>
<span class="sourceLineNo">1407</span>            poolableConnection = connection.unwrap(PoolableConnection.class);<a name="line.1407"></a>
<span class="sourceLineNo">1408</span>            if (poolableConnection == null) {<a name="line.1408"></a>
<span class="sourceLineNo">1409</span>                throw new IllegalStateException(<a name="line.1409"></a>
<span class="sourceLineNo">1410</span>                        "Cannot invalidate connection: Connection is not a poolable connection.");<a name="line.1410"></a>
<span class="sourceLineNo">1411</span>            }<a name="line.1411"></a>
<span class="sourceLineNo">1412</span>        } catch (final SQLException e) {<a name="line.1412"></a>
<span class="sourceLineNo">1413</span>            throw new IllegalStateException("Cannot invalidate connection: Unwrapping poolable connection failed.", e);<a name="line.1413"></a>
<span class="sourceLineNo">1414</span>        }<a name="line.1414"></a>
<span class="sourceLineNo">1415</span><a name="line.1415"></a>
<span class="sourceLineNo">1416</span>        try {<a name="line.1416"></a>
<span class="sourceLineNo">1417</span>            connectionPool.invalidateObject(poolableConnection);<a name="line.1417"></a>
<span class="sourceLineNo">1418</span>        } catch (final Exception e) {<a name="line.1418"></a>
<span class="sourceLineNo">1419</span>            throw new IllegalStateException("Invalidating connection threw unexpected exception", e);<a name="line.1419"></a>
<span class="sourceLineNo">1420</span>        }<a name="line.1420"></a>
<span class="sourceLineNo">1421</span>    }<a name="line.1421"></a>
<span class="sourceLineNo">1422</span><a name="line.1422"></a>
<span class="sourceLineNo">1423</span>    /**<a name="line.1423"></a>
<span class="sourceLineNo">1424</span>     * Returns the value of the accessToUnderlyingConnectionAllowed property.<a name="line.1424"></a>
<span class="sourceLineNo">1425</span>     *<a name="line.1425"></a>
<span class="sourceLineNo">1426</span>     * @return true if access to the underlying connection is allowed, false otherwise.<a name="line.1426"></a>
<span class="sourceLineNo">1427</span>     */<a name="line.1427"></a>
<span class="sourceLineNo">1428</span>    @Override<a name="line.1428"></a>
<span class="sourceLineNo">1429</span>    public synchronized boolean isAccessToUnderlyingConnectionAllowed() {<a name="line.1429"></a>
<span class="sourceLineNo">1430</span>        return this.accessToUnderlyingConnectionAllowed;<a name="line.1430"></a>
<span class="sourceLineNo">1431</span>    }<a name="line.1431"></a>
<span class="sourceLineNo">1432</span><a name="line.1432"></a>
<span class="sourceLineNo">1433</span>    /**<a name="line.1433"></a>
<span class="sourceLineNo">1434</span>     * Returns true if the statement pool is cleared when the connection is returned to its pool.<a name="line.1434"></a>
<span class="sourceLineNo">1435</span>     *<a name="line.1435"></a>
<span class="sourceLineNo">1436</span>     * @return true if the statement pool is cleared at connection return<a name="line.1436"></a>
<span class="sourceLineNo">1437</span>     * @since 2.8.0<a name="line.1437"></a>
<span class="sourceLineNo">1438</span>     */<a name="line.1438"></a>
<span class="sourceLineNo">1439</span>    @Override<a name="line.1439"></a>
<span class="sourceLineNo">1440</span>    public boolean isClearStatementPoolOnReturn() {<a name="line.1440"></a>
<span class="sourceLineNo">1441</span>        return clearStatementPoolOnReturn;<a name="line.1441"></a>
<span class="sourceLineNo">1442</span>    }<a name="line.1442"></a>
<span class="sourceLineNo">1443</span><a name="line.1443"></a>
<span class="sourceLineNo">1444</span>    /**<a name="line.1444"></a>
<span class="sourceLineNo">1445</span>     * If true, this data source is closed and no more connections can be retrieved from this data source.<a name="line.1445"></a>
<span class="sourceLineNo">1446</span>     *<a name="line.1446"></a>
<span class="sourceLineNo">1447</span>     * @return true, if the data source is closed; false otherwise<a name="line.1447"></a>
<span class="sourceLineNo">1448</span>     */<a name="line.1448"></a>
<span class="sourceLineNo">1449</span>    @Override<a name="line.1449"></a>
<span class="sourceLineNo">1450</span>    public synchronized boolean isClosed() {<a name="line.1450"></a>
<span class="sourceLineNo">1451</span>        return closed;<a name="line.1451"></a>
<span class="sourceLineNo">1452</span>    }<a name="line.1452"></a>
<span class="sourceLineNo">1453</span><a name="line.1453"></a>
<span class="sourceLineNo">1454</span>    /**<a name="line.1454"></a>
<span class="sourceLineNo">1455</span>     * Delegates in a null-safe manner to {@link String#isEmpty()}.<a name="line.1455"></a>
<span class="sourceLineNo">1456</span>     *<a name="line.1456"></a>
<span class="sourceLineNo">1457</span>     * @param value the string to test, may be null.<a name="line.1457"></a>
<span class="sourceLineNo">1458</span>     * @return boolean false if value is null, otherwise {@link String#isEmpty()}.<a name="line.1458"></a>
<span class="sourceLineNo">1459</span>     */<a name="line.1459"></a>
<span class="sourceLineNo">1460</span>    private boolean isEmpty(final String value) {<a name="line.1460"></a>
<span class="sourceLineNo">1461</span>        return value == null || value.trim().isEmpty();<a name="line.1461"></a>
<span class="sourceLineNo">1462</span>    }<a name="line.1462"></a>
<span class="sourceLineNo">1463</span><a name="line.1463"></a>
<span class="sourceLineNo">1464</span>    /**<a name="line.1464"></a>
<span class="sourceLineNo">1465</span>     * Returns true if we are pooling statements.<a name="line.1465"></a>
<span class="sourceLineNo">1466</span>     *<a name="line.1466"></a>
<span class="sourceLineNo">1467</span>     * @return true if prepared and callable statements are pooled<a name="line.1467"></a>
<span class="sourceLineNo">1468</span>     */<a name="line.1468"></a>
<span class="sourceLineNo">1469</span>    @Override<a name="line.1469"></a>
<span class="sourceLineNo">1470</span>    public synchronized boolean isPoolPreparedStatements() {<a name="line.1470"></a>
<span class="sourceLineNo">1471</span>        return this.poolPreparedStatements;<a name="line.1471"></a>
<span class="sourceLineNo">1472</span>    }<a name="line.1472"></a>
<span class="sourceLineNo">1473</span><a name="line.1473"></a>
<span class="sourceLineNo">1474</span>    @Override<a name="line.1474"></a>
<span class="sourceLineNo">1475</span>    public boolean isWrapperFor(final Class&lt;?&gt; iface) throws SQLException {<a name="line.1475"></a>
<span class="sourceLineNo">1476</span>        return iface != null &amp;&amp; iface.isInstance(this);<a name="line.1476"></a>
<span class="sourceLineNo">1477</span>    }<a name="line.1477"></a>
<span class="sourceLineNo">1478</span><a name="line.1478"></a>
<span class="sourceLineNo">1479</span>    private void jmxRegister() {<a name="line.1479"></a>
<span class="sourceLineNo">1480</span>        // Return immediately if this DataSource has already been registered<a name="line.1480"></a>
<span class="sourceLineNo">1481</span>        if (registeredJmxObjectName != null) {<a name="line.1481"></a>
<span class="sourceLineNo">1482</span>            return;<a name="line.1482"></a>
<span class="sourceLineNo">1483</span>        }<a name="line.1483"></a>
<span class="sourceLineNo">1484</span>        // Return immediately if no JMX name has been specified<a name="line.1484"></a>
<span class="sourceLineNo">1485</span>        final String requestedName = getJmxName();<a name="line.1485"></a>
<span class="sourceLineNo">1486</span>        if (requestedName == null) {<a name="line.1486"></a>
<span class="sourceLineNo">1487</span>            return;<a name="line.1487"></a>
<span class="sourceLineNo">1488</span>        }<a name="line.1488"></a>
<span class="sourceLineNo">1489</span>        registeredJmxObjectName = registerJmxObjectName(requestedName, null);<a name="line.1489"></a>
<span class="sourceLineNo">1490</span>        try {<a name="line.1490"></a>
<span class="sourceLineNo">1491</span>            final StandardMBean standardMBean = new StandardMBean(this, DataSourceMXBean.class);<a name="line.1491"></a>
<span class="sourceLineNo">1492</span>            registeredJmxObjectName.registerMBean(standardMBean);<a name="line.1492"></a>
<span class="sourceLineNo">1493</span>        } catch (final NotCompliantMBeanException e) {<a name="line.1493"></a>
<span class="sourceLineNo">1494</span>            log.warn("The requested JMX name [" + requestedName + "] was not valid and will be ignored.");<a name="line.1494"></a>
<span class="sourceLineNo">1495</span>        }<a name="line.1495"></a>
<span class="sourceLineNo">1496</span>    }<a name="line.1496"></a>
<span class="sourceLineNo">1497</span><a name="line.1497"></a>
<span class="sourceLineNo">1498</span>    protected void log(final String message) {<a name="line.1498"></a>
<span class="sourceLineNo">1499</span>        if (logWriter != null) {<a name="line.1499"></a>
<span class="sourceLineNo">1500</span>            logWriter.println(message);<a name="line.1500"></a>
<span class="sourceLineNo">1501</span>        }<a name="line.1501"></a>
<span class="sourceLineNo">1502</span>    }<a name="line.1502"></a>
<span class="sourceLineNo">1503</span><a name="line.1503"></a>
<span class="sourceLineNo">1504</span>    /**<a name="line.1504"></a>
<span class="sourceLineNo">1505</span>     * Logs the given throwable.<a name="line.1505"></a>
<span class="sourceLineNo">1506</span>     * @param message TODO<a name="line.1506"></a>
<span class="sourceLineNo">1507</span>     * @param throwable the throwable.<a name="line.1507"></a>
<span class="sourceLineNo">1508</span>     *<a name="line.1508"></a>
<span class="sourceLineNo">1509</span>     * @since 2.7.0<a name="line.1509"></a>
<span class="sourceLineNo">1510</span>     */<a name="line.1510"></a>
<span class="sourceLineNo">1511</span>    protected void log(final String message, final Throwable throwable) {<a name="line.1511"></a>
<span class="sourceLineNo">1512</span>        if (logWriter != null) {<a name="line.1512"></a>
<span class="sourceLineNo">1513</span>            logWriter.println(message);<a name="line.1513"></a>
<span class="sourceLineNo">1514</span>            throwable.printStackTrace(logWriter);<a name="line.1514"></a>
<span class="sourceLineNo">1515</span>        }<a name="line.1515"></a>
<span class="sourceLineNo">1516</span>    }<a name="line.1516"></a>
<span class="sourceLineNo">1517</span><a name="line.1517"></a>
<span class="sourceLineNo">1518</span>    @Override<a name="line.1518"></a>
<span class="sourceLineNo">1519</span>    public void postDeregister() {<a name="line.1519"></a>
<span class="sourceLineNo">1520</span>        // NO-OP<a name="line.1520"></a>
<span class="sourceLineNo">1521</span>    }<a name="line.1521"></a>
<span class="sourceLineNo">1522</span><a name="line.1522"></a>
<span class="sourceLineNo">1523</span>    @Override<a name="line.1523"></a>
<span class="sourceLineNo">1524</span>    public void postRegister(final Boolean registrationDone) {<a name="line.1524"></a>
<span class="sourceLineNo">1525</span>        // NO-OP<a name="line.1525"></a>
<span class="sourceLineNo">1526</span>    }<a name="line.1526"></a>
<span class="sourceLineNo">1527</span><a name="line.1527"></a>
<span class="sourceLineNo">1528</span>    @Override<a name="line.1528"></a>
<span class="sourceLineNo">1529</span>    public void preDeregister() throws Exception {<a name="line.1529"></a>
<span class="sourceLineNo">1530</span>        // NO-OP<a name="line.1530"></a>
<span class="sourceLineNo">1531</span>    }<a name="line.1531"></a>
<span class="sourceLineNo">1532</span><a name="line.1532"></a>
<span class="sourceLineNo">1533</span>    @Override<a name="line.1533"></a>
<span class="sourceLineNo">1534</span>    public ObjectName preRegister(final MBeanServer server, final ObjectName objectName) {<a name="line.1534"></a>
<span class="sourceLineNo">1535</span>        registeredJmxObjectName = registerJmxObjectName(getJmxName(), objectName);<a name="line.1535"></a>
<span class="sourceLineNo">1536</span>        return ObjectNameWrapper.unwrap(registeredJmxObjectName);<a name="line.1536"></a>
<span class="sourceLineNo">1537</span>    }<a name="line.1537"></a>
<span class="sourceLineNo">1538</span><a name="line.1538"></a>
<span class="sourceLineNo">1539</span>    private ObjectNameWrapper registerJmxObjectName(final String requestedName, final ObjectName objectName) {<a name="line.1539"></a>
<span class="sourceLineNo">1540</span>        ObjectNameWrapper objectNameWrapper = null;<a name="line.1540"></a>
<span class="sourceLineNo">1541</span>        if (requestedName != null) {<a name="line.1541"></a>
<span class="sourceLineNo">1542</span>            try {<a name="line.1542"></a>
<span class="sourceLineNo">1543</span>                objectNameWrapper = ObjectNameWrapper.wrap(requestedName);<a name="line.1543"></a>
<span class="sourceLineNo">1544</span>            } catch (final MalformedObjectNameException e) {<a name="line.1544"></a>
<span class="sourceLineNo">1545</span>                log.warn("The requested JMX name '" + requestedName + "' was not valid and will be ignored.");<a name="line.1545"></a>
<span class="sourceLineNo">1546</span>            }<a name="line.1546"></a>
<span class="sourceLineNo">1547</span>        }<a name="line.1547"></a>
<span class="sourceLineNo">1548</span>        if (objectNameWrapper == null) {<a name="line.1548"></a>
<span class="sourceLineNo">1549</span>            objectNameWrapper = ObjectNameWrapper.wrap(objectName);<a name="line.1549"></a>
<span class="sourceLineNo">1550</span>        }<a name="line.1550"></a>
<span class="sourceLineNo">1551</span>        return objectNameWrapper;<a name="line.1551"></a>
<span class="sourceLineNo">1552</span>    }<a name="line.1552"></a>
<span class="sourceLineNo">1553</span><a name="line.1553"></a>
<span class="sourceLineNo">1554</span>    /**<a name="line.1554"></a>
<span class="sourceLineNo">1555</span>     * Removes a custom connection property.<a name="line.1555"></a>
<span class="sourceLineNo">1556</span>     *<a name="line.1556"></a>
<span class="sourceLineNo">1557</span>     * @param name Name of the custom connection property to remove<a name="line.1557"></a>
<span class="sourceLineNo">1558</span>     * @see #addConnectionProperty(String, String)<a name="line.1558"></a>
<span class="sourceLineNo">1559</span>     */<a name="line.1559"></a>
<span class="sourceLineNo">1560</span>    public void removeConnectionProperty(final String name) {<a name="line.1560"></a>
<span class="sourceLineNo">1561</span>        connectionProperties.remove(name);<a name="line.1561"></a>
<span class="sourceLineNo">1562</span>    }<a name="line.1562"></a>
<span class="sourceLineNo">1563</span><a name="line.1563"></a>
<span class="sourceLineNo">1564</span>    /**<a name="line.1564"></a>
<span class="sourceLineNo">1565</span>     * Restarts the datasource.<a name="line.1565"></a>
<span class="sourceLineNo">1566</span>     * &lt;p&gt;<a name="line.1566"></a>
<span class="sourceLineNo">1567</span>     * This method calls {@link #close()} and {@link #start()} in sequence within synchronized scope so any<a name="line.1567"></a>
<span class="sourceLineNo">1568</span>     * connection requests that come in while the datasource is shutting down will be served by the new pool.<a name="line.1568"></a>
<span class="sourceLineNo">1569</span>     * &lt;p&gt;<a name="line.1569"></a>
<span class="sourceLineNo">1570</span>     * Idle connections that are stored in the connection pool when this method is invoked are closed, but<a name="line.1570"></a>
<span class="sourceLineNo">1571</span>     * connections that are checked out to clients when this method is invoked are not affected. When client<a name="line.1571"></a>
<span class="sourceLineNo">1572</span>     * applications subsequently invoke {@link Connection#close()} to return these connections to the pool, the<a name="line.1572"></a>
<span class="sourceLineNo">1573</span>     * underlying JDBC connections are closed. These connections do not count in {@link #getMaxTotal()} or<a name="line.1573"></a>
<span class="sourceLineNo">1574</span>     * {@link #getNumActive()} after invoking this method. For example, if there are 3 connections checked out by<a name="line.1574"></a>
<span class="sourceLineNo">1575</span>     * clients when {@link #restart()} is invoked, after this method is called, {@link #getNumActive()} will<a name="line.1575"></a>
<span class="sourceLineNo">1576</span>     * return 0 and up to {@link #getMaxTotal()} + 3 connections may be open until the connections sourced from<a name="line.1576"></a>
<span class="sourceLineNo">1577</span>     * the original pool are returned.<a name="line.1577"></a>
<span class="sourceLineNo">1578</span>     * &lt;p&gt;<a name="line.1578"></a>
<span class="sourceLineNo">1579</span>     * The new connection pool created by this method is initialized with currently set configuration properties.<a name="line.1579"></a>
<span class="sourceLineNo">1580</span>     *<a name="line.1580"></a>
<span class="sourceLineNo">1581</span>     * @throws SQLException if an error occurs initializing the datasource<a name="line.1581"></a>
<span class="sourceLineNo">1582</span>     */<a name="line.1582"></a>
<span class="sourceLineNo">1583</span>    @Override<a name="line.1583"></a>
<span class="sourceLineNo">1584</span>    public synchronized void restart() throws SQLException {<a name="line.1584"></a>
<span class="sourceLineNo">1585</span>        close();<a name="line.1585"></a>
<span class="sourceLineNo">1586</span>        start();<a name="line.1586"></a>
<span class="sourceLineNo">1587</span>    }<a name="line.1587"></a>
<span class="sourceLineNo">1588</span><a name="line.1588"></a>
<span class="sourceLineNo">1589</span>    /**<a name="line.1589"></a>
<span class="sourceLineNo">1590</span>     * Sets the print writer to be used by this configuration to log information on abandoned objects.<a name="line.1590"></a>
<span class="sourceLineNo">1591</span>     *<a name="line.1591"></a>
<span class="sourceLineNo">1592</span>     * @param logWriter The new log writer<a name="line.1592"></a>
<span class="sourceLineNo">1593</span>     */<a name="line.1593"></a>
<span class="sourceLineNo">1594</span>    public void setAbandonedLogWriter(final PrintWriter logWriter) {<a name="line.1594"></a>
<span class="sourceLineNo">1595</span>        if (abandonedConfig == null) {<a name="line.1595"></a>
<span class="sourceLineNo">1596</span>            abandonedConfig = new AbandonedConfig();<a name="line.1596"></a>
<span class="sourceLineNo">1597</span>        }<a name="line.1597"></a>
<span class="sourceLineNo">1598</span>        abandonedConfig.setLogWriter(logWriter);<a name="line.1598"></a>
<span class="sourceLineNo">1599</span>        final GenericObjectPool&lt;?&gt; gop = this.connectionPool;<a name="line.1599"></a>
<span class="sourceLineNo">1600</span>        if (gop != null) {<a name="line.1600"></a>
<span class="sourceLineNo">1601</span>            gop.setAbandonedConfig(abandonedConfig);<a name="line.1601"></a>
<span class="sourceLineNo">1602</span>        }<a name="line.1602"></a>
<span class="sourceLineNo">1603</span>    }<a name="line.1603"></a>
<span class="sourceLineNo">1604</span><a name="line.1604"></a>
<span class="sourceLineNo">1605</span>    /**<a name="line.1605"></a>
<span class="sourceLineNo">1606</span>     * If the connection pool implements {@link org.apache.commons.pool2.UsageTracking UsageTracking}, configure whether<a name="line.1606"></a>
<span class="sourceLineNo">1607</span>     * the connection pool should record a stack trace every time a method is called on a pooled connection and retain<a name="line.1607"></a>
<span class="sourceLineNo">1608</span>     * the most recent stack trace to aid debugging of abandoned connections.<a name="line.1608"></a>
<span class="sourceLineNo">1609</span>     *<a name="line.1609"></a>
<span class="sourceLineNo">1610</span>     * @param usageTracking A value of &lt;code&gt;true&lt;/code&gt; will enable the recording of a stack trace on every use of a<a name="line.1610"></a>
<span class="sourceLineNo">1611</span>     *                      pooled connection<a name="line.1611"></a>
<span class="sourceLineNo">1612</span>     */<a name="line.1612"></a>
<span class="sourceLineNo">1613</span>    public void setAbandonedUsageTracking(final boolean usageTracking) {<a name="line.1613"></a>
<span class="sourceLineNo">1614</span>        if (abandonedConfig == null) {<a name="line.1614"></a>
<span class="sourceLineNo">1615</span>            abandonedConfig = new AbandonedConfig();<a name="line.1615"></a>
<span class="sourceLineNo">1616</span>        }<a name="line.1616"></a>
<span class="sourceLineNo">1617</span>        abandonedConfig.setUseUsageTracking(usageTracking);<a name="line.1617"></a>
<span class="sourceLineNo">1618</span>        final GenericObjectPool&lt;?&gt; gop = this.connectionPool;<a name="line.1618"></a>
<span class="sourceLineNo">1619</span>        if (gop != null) {<a name="line.1619"></a>
<span class="sourceLineNo">1620</span>            gop.setAbandonedConfig(abandonedConfig);<a name="line.1620"></a>
<span class="sourceLineNo">1621</span>        }<a name="line.1621"></a>
<span class="sourceLineNo">1622</span>    }<a name="line.1622"></a>
<span class="sourceLineNo">1623</span><a name="line.1623"></a>
<span class="sourceLineNo">1624</span>    /**<a name="line.1624"></a>
<span class="sourceLineNo">1625</span>     * &lt;p&gt;<a name="line.1625"></a>
<span class="sourceLineNo">1626</span>     * Sets the value of the accessToUnderlyingConnectionAllowed property. It controls if the PoolGuard allows access to<a name="line.1626"></a>
<span class="sourceLineNo">1627</span>     * the underlying connection. (Default: false)<a name="line.1627"></a>
<span class="sourceLineNo">1628</span>     * &lt;/p&gt;<a name="line.1628"></a>
<span class="sourceLineNo">1629</span>     * &lt;p&gt;<a name="line.1629"></a>
<span class="sourceLineNo">1630</span>     * Note: this method currently has no effect once the pool has been initialized. The pool is initialized the first<a name="line.1630"></a>
<span class="sourceLineNo">1631</span>     * time one of the following methods is invoked: &lt;code&gt;getConnection, setLogwriter,<a name="line.1631"></a>
<span class="sourceLineNo">1632</span>     * setLoginTimeout, getLoginTimeout, getLogWriter.&lt;/code&gt;<a name="line.1632"></a>
<span class="sourceLineNo">1633</span>     * &lt;/p&gt;<a name="line.1633"></a>
<span class="sourceLineNo">1634</span>     *<a name="line.1634"></a>
<span class="sourceLineNo">1635</span>     * @param allow Access to the underlying connection is granted when true.<a name="line.1635"></a>
<span class="sourceLineNo">1636</span>     */<a name="line.1636"></a>
<span class="sourceLineNo">1637</span>    public synchronized void setAccessToUnderlyingConnectionAllowed(final boolean allow) {<a name="line.1637"></a>
<span class="sourceLineNo">1638</span>        this.accessToUnderlyingConnectionAllowed = allow;<a name="line.1638"></a>
<span class="sourceLineNo">1639</span>    }<a name="line.1639"></a>
<span class="sourceLineNo">1640</span><a name="line.1640"></a>
<span class="sourceLineNo">1641</span>    /**<a name="line.1641"></a>
<span class="sourceLineNo">1642</span>     * Sets the value of the flag that controls whether or not connections being returned to the pool will be checked<a name="line.1642"></a>
<span class="sourceLineNo">1643</span>     * and configured with {@link Connection#setAutoCommit(boolean) Connection.setAutoCommit(true)} if the auto commit<a name="line.1643"></a>
<span class="sourceLineNo">1644</span>     * setting is {@code false} when the connection is returned. It is &lt;code&gt;true&lt;/code&gt; by default.<a name="line.1644"></a>
<span class="sourceLineNo">1645</span>     *<a name="line.1645"></a>
<span class="sourceLineNo">1646</span>     * @param autoCommitOnReturn Whether or not connections being returned to the pool will be checked and configured<a name="line.1646"></a>
<span class="sourceLineNo">1647</span>     *                           with auto-commit.<a name="line.1647"></a>
<span class="sourceLineNo">1648</span>     * @since 2.6.0<a name="line.1648"></a>
<span class="sourceLineNo">1649</span>     */<a name="line.1649"></a>
<span class="sourceLineNo">1650</span>    public void setAutoCommitOnReturn(final boolean autoCommitOnReturn) {<a name="line.1650"></a>
<span class="sourceLineNo">1651</span>        this.autoCommitOnReturn = autoCommitOnReturn;<a name="line.1651"></a>
<span class="sourceLineNo">1652</span>    }<a name="line.1652"></a>
<span class="sourceLineNo">1653</span><a name="line.1653"></a>
<span class="sourceLineNo">1654</span>    /**<a name="line.1654"></a>
<span class="sourceLineNo">1655</span>     * Sets the state caching flag.<a name="line.1655"></a>
<span class="sourceLineNo">1656</span>     *<a name="line.1656"></a>
<span class="sourceLineNo">1657</span>     * @param cacheState The new value for the state caching flag<a name="line.1657"></a>
<span class="sourceLineNo">1658</span>     */<a name="line.1658"></a>
<span class="sourceLineNo">1659</span>    public void setCacheState(final boolean cacheState) {<a name="line.1659"></a>
<span class="sourceLineNo">1660</span>        this.cacheState = cacheState;<a name="line.1660"></a>
<span class="sourceLineNo">1661</span>    }<a name="line.1661"></a>
<span class="sourceLineNo">1662</span><a name="line.1662"></a>
<span class="sourceLineNo">1663</span>    /**<a name="line.1663"></a>
<span class="sourceLineNo">1664</span>     * Sets whether the pool of statements (which was enabled with {@link #setPoolPreparedStatements(boolean)}) should<a name="line.1664"></a>
<span class="sourceLineNo">1665</span>     * be cleared when the connection is returned to its pool. Default is false.<a name="line.1665"></a>
<span class="sourceLineNo">1666</span>     *<a name="line.1666"></a>
<span class="sourceLineNo">1667</span>     * @param clearStatementPoolOnReturn clear or not<a name="line.1667"></a>
<span class="sourceLineNo">1668</span>     * @since 2.8.0<a name="line.1668"></a>
<span class="sourceLineNo">1669</span>     */<a name="line.1669"></a>
<span class="sourceLineNo">1670</span>    public void setClearStatementPoolOnReturn(final boolean clearStatementPoolOnReturn) {<a name="line.1670"></a>
<span class="sourceLineNo">1671</span>        this.clearStatementPoolOnReturn = clearStatementPoolOnReturn;<a name="line.1671"></a>
<span class="sourceLineNo">1672</span>    }<a name="line.1672"></a>
<span class="sourceLineNo">1673</span><a name="line.1673"></a>
<span class="sourceLineNo">1674</span>    /**<a name="line.1674"></a>
<span class="sourceLineNo">1675</span>     * Sets the ConnectionFactory class name.<a name="line.1675"></a>
<span class="sourceLineNo">1676</span>     *<a name="line.1676"></a>
<span class="sourceLineNo">1677</span>     * @param connectionFactoryClassName A class name.<a name="line.1677"></a>
<span class="sourceLineNo">1678</span>     * @since 2.7.0<a name="line.1678"></a>
<span class="sourceLineNo">1679</span>     */<a name="line.1679"></a>
<span class="sourceLineNo">1680</span>    public void setConnectionFactoryClassName(final String connectionFactoryClassName) {<a name="line.1680"></a>
<span class="sourceLineNo">1681</span>        this.connectionFactoryClassName = isEmpty(connectionFactoryClassName) ? null : connectionFactoryClassName;<a name="line.1681"></a>
<span class="sourceLineNo">1682</span>    }<a name="line.1682"></a>
<span class="sourceLineNo">1683</span><a name="line.1683"></a>
<span class="sourceLineNo">1684</span>    /**<a name="line.1684"></a>
<span class="sourceLineNo">1685</span>     * Sets the list of SQL statements to be executed when a physical connection is first created.<a name="line.1685"></a>
<span class="sourceLineNo">1686</span>     * &lt;p&gt;<a name="line.1686"></a>
<span class="sourceLineNo">1687</span>     * Note: this method currently has no effect once the pool has been initialized. The pool is initialized the first<a name="line.1687"></a>
<span class="sourceLineNo">1688</span>     * time one of the following methods is invoked: &lt;code&gt;getConnection, setLogwriter,<a name="line.1688"></a>
<span class="sourceLineNo">1689</span>     * setLoginTimeout, getLoginTimeout, getLogWriter.&lt;/code&gt;<a name="line.1689"></a>
<span class="sourceLineNo">1690</span>     * &lt;/p&gt;<a name="line.1690"></a>
<span class="sourceLineNo">1691</span>     *<a name="line.1691"></a>
<span class="sourceLineNo">1692</span>     * @param connectionInitSqls Collection of SQL statements to execute on connection creation<a name="line.1692"></a>
<span class="sourceLineNo">1693</span>     */<a name="line.1693"></a>
<span class="sourceLineNo">1694</span>    public void setConnectionInitSqls(final Collection&lt;String&gt; connectionInitSqls) {<a name="line.1694"></a>
<span class="sourceLineNo">1695</span>        if (connectionInitSqls != null &amp;&amp; !connectionInitSqls.isEmpty()) {<a name="line.1695"></a>
<span class="sourceLineNo">1696</span>            ArrayList&lt;String&gt; newVal = null;<a name="line.1696"></a>
<span class="sourceLineNo">1697</span>            for (final String s : connectionInitSqls) {<a name="line.1697"></a>
<span class="sourceLineNo">1698</span>                if (!isEmpty(s)) {<a name="line.1698"></a>
<span class="sourceLineNo">1699</span>                    if (newVal == null) {<a name="line.1699"></a>
<span class="sourceLineNo">1700</span>                        newVal = new ArrayList&lt;&gt;();<a name="line.1700"></a>
<span class="sourceLineNo">1701</span>                    }<a name="line.1701"></a>
<span class="sourceLineNo">1702</span>                    newVal.add(s);<a name="line.1702"></a>
<span class="sourceLineNo">1703</span>                }<a name="line.1703"></a>
<span class="sourceLineNo">1704</span>            }<a name="line.1704"></a>
<span class="sourceLineNo">1705</span>            this.connectionInitSqls = newVal;<a name="line.1705"></a>
<span class="sourceLineNo">1706</span>        } else {<a name="line.1706"></a>
<span class="sourceLineNo">1707</span>            this.connectionInitSqls = null;<a name="line.1707"></a>
<span class="sourceLineNo">1708</span>        }<a name="line.1708"></a>
<span class="sourceLineNo">1709</span>    }<a name="line.1709"></a>
<span class="sourceLineNo">1710</span><a name="line.1710"></a>
<span class="sourceLineNo">1711</span>    /**<a name="line.1711"></a>
<span class="sourceLineNo">1712</span>     * Sets the connection properties passed to driver.connect(...).<a name="line.1712"></a>
<span class="sourceLineNo">1713</span>     * &lt;p&gt;<a name="line.1713"></a>
<span class="sourceLineNo">1714</span>     * Format of the string must be [propertyName=property;]*<a name="line.1714"></a>
<span class="sourceLineNo">1715</span>     * &lt;/p&gt;<a name="line.1715"></a>
<span class="sourceLineNo">1716</span>     * &lt;p&gt;<a name="line.1716"></a>
<span class="sourceLineNo">1717</span>     * NOTE - The "user" and "password" properties will be added explicitly, so they do not need to be included here.<a name="line.1717"></a>
<span class="sourceLineNo">1718</span>     * &lt;/p&gt;<a name="line.1718"></a>
<span class="sourceLineNo">1719</span>     *<a name="line.1719"></a>
<span class="sourceLineNo">1720</span>     * @param connectionProperties the connection properties used to create new connections<a name="line.1720"></a>
<span class="sourceLineNo">1721</span>     */<a name="line.1721"></a>
<span class="sourceLineNo">1722</span>    public void setConnectionProperties(final String connectionProperties) {<a name="line.1722"></a>
<span class="sourceLineNo">1723</span>        Objects.requireNonNull(connectionProperties, "connectionProperties is null");<a name="line.1723"></a>
<span class="sourceLineNo">1724</span>        final String[] entries = connectionProperties.split(";");<a name="line.1724"></a>
<span class="sourceLineNo">1725</span>        final Properties properties = new Properties();<a name="line.1725"></a>
<span class="sourceLineNo">1726</span>        for (final String entry : entries) {<a name="line.1726"></a>
<span class="sourceLineNo">1727</span>            if (!entry.isEmpty()) {<a name="line.1727"></a>
<span class="sourceLineNo">1728</span>                final int index = entry.indexOf('=');<a name="line.1728"></a>
<span class="sourceLineNo">1729</span>                if (index &gt; 0) {<a name="line.1729"></a>
<span class="sourceLineNo">1730</span>                    final String name = entry.substring(0, index);<a name="line.1730"></a>
<span class="sourceLineNo">1731</span>                    final String value = entry.substring(index + 1);<a name="line.1731"></a>
<span class="sourceLineNo">1732</span>                    properties.setProperty(name, value);<a name="line.1732"></a>
<span class="sourceLineNo">1733</span>                } else {<a name="line.1733"></a>
<span class="sourceLineNo">1734</span>                    // no value is empty string which is how<a name="line.1734"></a>
<span class="sourceLineNo">1735</span>                    // java.util.Properties works<a name="line.1735"></a>
<span class="sourceLineNo">1736</span>                    properties.setProperty(entry, "");<a name="line.1736"></a>
<span class="sourceLineNo">1737</span>                }<a name="line.1737"></a>
<span class="sourceLineNo">1738</span>            }<a name="line.1738"></a>
<span class="sourceLineNo">1739</span>        }<a name="line.1739"></a>
<span class="sourceLineNo">1740</span>        this.connectionProperties = properties;<a name="line.1740"></a>
<span class="sourceLineNo">1741</span>    }<a name="line.1741"></a>
<span class="sourceLineNo">1742</span><a name="line.1742"></a>
<span class="sourceLineNo">1743</span>    /**<a name="line.1743"></a>
<span class="sourceLineNo">1744</span>     * &lt;p&gt;<a name="line.1744"></a>
<span class="sourceLineNo">1745</span>     * Sets default auto-commit state of connections returned by this datasource.<a name="line.1745"></a>
<span class="sourceLineNo">1746</span>     * &lt;/p&gt;<a name="line.1746"></a>
<span class="sourceLineNo">1747</span>     * &lt;p&gt;<a name="line.1747"></a>
<span class="sourceLineNo">1748</span>     * Note: this method currently has no effect once the pool has been initialized. The pool is initialized the first<a name="line.1748"></a>
<span class="sourceLineNo">1749</span>     * time one of the following methods is invoked: &lt;code&gt;getConnection, setLogwriter,<a name="line.1749"></a>
<span class="sourceLineNo">1750</span>     * setLoginTimeout, getLoginTimeout, getLogWriter.&lt;/code&gt;<a name="line.1750"></a>
<span class="sourceLineNo">1751</span>     * &lt;/p&gt;<a name="line.1751"></a>
<span class="sourceLineNo">1752</span>     *<a name="line.1752"></a>
<span class="sourceLineNo">1753</span>     * @param defaultAutoCommit default auto-commit value<a name="line.1753"></a>
<span class="sourceLineNo">1754</span>     */<a name="line.1754"></a>
<span class="sourceLineNo">1755</span>    public void setDefaultAutoCommit(final Boolean defaultAutoCommit) {<a name="line.1755"></a>
<span class="sourceLineNo">1756</span>        this.defaultAutoCommit = defaultAutoCommit;<a name="line.1756"></a>
<span class="sourceLineNo">1757</span>    }<a name="line.1757"></a>
<span class="sourceLineNo">1758</span><a name="line.1758"></a>
<span class="sourceLineNo">1759</span>    /**<a name="line.1759"></a>
<span class="sourceLineNo">1760</span>     * &lt;p&gt;<a name="line.1760"></a>
<span class="sourceLineNo">1761</span>     * Sets the default catalog.<a name="line.1761"></a>
<span class="sourceLineNo">1762</span>     * &lt;/p&gt;<a name="line.1762"></a>
<span class="sourceLineNo">1763</span>     * &lt;p&gt;<a name="line.1763"></a>
<span class="sourceLineNo">1764</span>     * Note: this method currently has no effect once the pool has been initialized. The pool is initialized the first<a name="line.1764"></a>
<span class="sourceLineNo">1765</span>     * time one of the following methods is invoked: &lt;code&gt;getConnection, setLogwriter,<a name="line.1765"></a>
<span class="sourceLineNo">1766</span>     * setLoginTimeout, getLoginTimeout, getLogWriter.&lt;/code&gt;<a name="line.1766"></a>
<span class="sourceLineNo">1767</span>     * &lt;/p&gt;<a name="line.1767"></a>
<span class="sourceLineNo">1768</span>     *<a name="line.1768"></a>
<span class="sourceLineNo">1769</span>     * @param defaultCatalog the default catalog<a name="line.1769"></a>
<span class="sourceLineNo">1770</span>     */<a name="line.1770"></a>
<span class="sourceLineNo">1771</span>    public void setDefaultCatalog(final String defaultCatalog) {<a name="line.1771"></a>
<span class="sourceLineNo">1772</span>        this.defaultCatalog = isEmpty(defaultCatalog) ? null : defaultCatalog;<a name="line.1772"></a>
<span class="sourceLineNo">1773</span>    }<a name="line.1773"></a>
<span class="sourceLineNo">1774</span><a name="line.1774"></a>
<span class="sourceLineNo">1775</span>    /**<a name="line.1775"></a>
<span class="sourceLineNo">1776</span>     * Sets the default query timeout that will be used for {@link java.sql.Statement Statement}s created from this<a name="line.1776"></a>
<span class="sourceLineNo">1777</span>     * connection. &lt;code&gt;null&lt;/code&gt; means that the driver default will be used.<a name="line.1777"></a>
<span class="sourceLineNo">1778</span>     *<a name="line.1778"></a>
<span class="sourceLineNo">1779</span>     * @param defaultQueryTimeoutSeconds The default query timeout in seconds.<a name="line.1779"></a>
<span class="sourceLineNo">1780</span>     */<a name="line.1780"></a>
<span class="sourceLineNo">1781</span>    public void setDefaultQueryTimeout(final Integer defaultQueryTimeoutSeconds) {<a name="line.1781"></a>
<span class="sourceLineNo">1782</span>        this.defaultQueryTimeoutSeconds = defaultQueryTimeoutSeconds;<a name="line.1782"></a>
<span class="sourceLineNo">1783</span>    }<a name="line.1783"></a>
<span class="sourceLineNo">1784</span><a name="line.1784"></a>
<span class="sourceLineNo">1785</span>    /**<a name="line.1785"></a>
<span class="sourceLineNo">1786</span>     * &lt;p&gt;<a name="line.1786"></a>
<span class="sourceLineNo">1787</span>     * Sets defaultReadonly property.<a name="line.1787"></a>
<span class="sourceLineNo">1788</span>     * &lt;/p&gt;<a name="line.1788"></a>
<span class="sourceLineNo">1789</span>     * &lt;p&gt;<a name="line.1789"></a>
<span class="sourceLineNo">1790</span>     * Note: this method currently has no effect once the pool has been initialized. The pool is initialized the first<a name="line.1790"></a>
<span class="sourceLineNo">1791</span>     * time one of the following methods is invoked: &lt;code&gt;getConnection, setLogwriter,<a name="line.1791"></a>
<span class="sourceLineNo">1792</span>     * setLoginTimeout, getLoginTimeout, getLogWriter.&lt;/code&gt;<a name="line.1792"></a>
<span class="sourceLineNo">1793</span>     * &lt;/p&gt;<a name="line.1793"></a>
<span class="sourceLineNo">1794</span>     *<a name="line.1794"></a>
<span class="sourceLineNo">1795</span>     * @param defaultReadOnly default read-only value<a name="line.1795"></a>
<span class="sourceLineNo">1796</span>     */<a name="line.1796"></a>
<span class="sourceLineNo">1797</span>    public void setDefaultReadOnly(final Boolean defaultReadOnly) {<a name="line.1797"></a>
<span class="sourceLineNo">1798</span>        this.defaultReadOnly = defaultReadOnly;<a name="line.1798"></a>
<span class="sourceLineNo">1799</span>    }<a name="line.1799"></a>
<span class="sourceLineNo">1800</span><a name="line.1800"></a>
<span class="sourceLineNo">1801</span>    /**<a name="line.1801"></a>
<span class="sourceLineNo">1802</span>     * &lt;p&gt;<a name="line.1802"></a>
<span class="sourceLineNo">1803</span>     * Sets the default schema.<a name="line.1803"></a>
<span class="sourceLineNo">1804</span>     * &lt;/p&gt;<a name="line.1804"></a>
<span class="sourceLineNo">1805</span>     * &lt;p&gt;<a name="line.1805"></a>
<span class="sourceLineNo">1806</span>     * Note: this method currently has no effect once the pool has been initialized. The pool is initialized the first<a name="line.1806"></a>
<span class="sourceLineNo">1807</span>     * time one of the following methods is invoked: &lt;code&gt;getConnection, setLogwriter,<a name="line.1807"></a>
<span class="sourceLineNo">1808</span>     * setLoginTimeout, getLoginTimeout, getLogWriter.&lt;/code&gt;<a name="line.1808"></a>
<span class="sourceLineNo">1809</span>     * &lt;/p&gt;<a name="line.1809"></a>
<span class="sourceLineNo">1810</span>     *<a name="line.1810"></a>
<span class="sourceLineNo">1811</span>     * @param defaultSchema the default catalog<a name="line.1811"></a>
<span class="sourceLineNo">1812</span>     * @since 2.5.0<a name="line.1812"></a>
<span class="sourceLineNo">1813</span>     */<a name="line.1813"></a>
<span class="sourceLineNo">1814</span>    public void setDefaultSchema(final String defaultSchema) {<a name="line.1814"></a>
<span class="sourceLineNo">1815</span>        this.defaultSchema = isEmpty(defaultSchema) ? null : defaultSchema;<a name="line.1815"></a>
<span class="sourceLineNo">1816</span>    }<a name="line.1816"></a>
<span class="sourceLineNo">1817</span><a name="line.1817"></a>
<span class="sourceLineNo">1818</span>    /**<a name="line.1818"></a>
<span class="sourceLineNo">1819</span>     * &lt;p&gt;<a name="line.1819"></a>
<span class="sourceLineNo">1820</span>     * Sets the default transaction isolation state for returned connections.<a name="line.1820"></a>
<span class="sourceLineNo">1821</span>     * &lt;/p&gt;<a name="line.1821"></a>
<span class="sourceLineNo">1822</span>     * &lt;p&gt;<a name="line.1822"></a>
<span class="sourceLineNo">1823</span>     * Note: this method currently has no effect once the pool has been initialized. The pool is initialized the first<a name="line.1823"></a>
<span class="sourceLineNo">1824</span>     * time one of the following methods is invoked: &lt;code&gt;getConnection, setLogwriter,<a name="line.1824"></a>
<span class="sourceLineNo">1825</span>     * setLoginTimeout, getLoginTimeout, getLogWriter.&lt;/code&gt;<a name="line.1825"></a>
<span class="sourceLineNo">1826</span>     * &lt;/p&gt;<a name="line.1826"></a>
<span class="sourceLineNo">1827</span>     *<a name="line.1827"></a>
<span class="sourceLineNo">1828</span>     * @param defaultTransactionIsolation the default transaction isolation state<a name="line.1828"></a>
<span class="sourceLineNo">1829</span>     * @see Connection#getTransactionIsolation<a name="line.1829"></a>
<span class="sourceLineNo">1830</span>     */<a name="line.1830"></a>
<span class="sourceLineNo">1831</span>    public void setDefaultTransactionIsolation(final int defaultTransactionIsolation) {<a name="line.1831"></a>
<span class="sourceLineNo">1832</span>        this.defaultTransactionIsolation = defaultTransactionIsolation;<a name="line.1832"></a>
<span class="sourceLineNo">1833</span>    }<a name="line.1833"></a>
<span class="sourceLineNo">1834</span><a name="line.1834"></a>
<span class="sourceLineNo">1835</span>    /**<a name="line.1835"></a>
<span class="sourceLineNo">1836</span>     * Sets the SQL_STATE codes considered to signal fatal conditions.<a name="line.1836"></a>
<span class="sourceLineNo">1837</span>     * &lt;p&gt;<a name="line.1837"></a>
<span class="sourceLineNo">1838</span>     * Overrides the defaults in {@link Utils#DISCONNECTION_SQL_CODES} (plus anything starting with<a name="line.1838"></a>
<span class="sourceLineNo">1839</span>     * {@link Utils#DISCONNECTION_SQL_CODE_PREFIX}). If this property is non-null and {@link #getFastFailValidation()}<a name="line.1839"></a>
<span class="sourceLineNo">1840</span>     * is {@code true}, whenever connections created by this datasource generate exceptions with SQL_STATE codes in this<a name="line.1840"></a>
<span class="sourceLineNo">1841</span>     * list, they will be marked as "fatally disconnected" and subsequent validations will fail fast (no attempt at<a name="line.1841"></a>
<span class="sourceLineNo">1842</span>     * isValid or validation query).<a name="line.1842"></a>
<span class="sourceLineNo">1843</span>     * &lt;/p&gt;<a name="line.1843"></a>
<span class="sourceLineNo">1844</span>     * &lt;p&gt;<a name="line.1844"></a>
<span class="sourceLineNo">1845</span>     * If {@link #getFastFailValidation()} is {@code false} setting this property has no effect.<a name="line.1845"></a>
<span class="sourceLineNo">1846</span>     * &lt;/p&gt;<a name="line.1846"></a>
<span class="sourceLineNo">1847</span>     * &lt;p&gt;<a name="line.1847"></a>
<span class="sourceLineNo">1848</span>     * Note: this method currently has no effect once the pool has been initialized. The pool is initialized the first<a name="line.1848"></a>
<span class="sourceLineNo">1849</span>     * time one of the following methods is invoked: {@code getConnection, setLogwriter,<a name="line.1849"></a>
<span class="sourceLineNo">1850</span>     * setLoginTimeout, getLoginTimeout, getLogWriter}.<a name="line.1850"></a>
<span class="sourceLineNo">1851</span>     * &lt;/p&gt;<a name="line.1851"></a>
<span class="sourceLineNo">1852</span>     *<a name="line.1852"></a>
<span class="sourceLineNo">1853</span>     * @param disconnectionSqlCodes SQL_STATE codes considered to signal fatal conditions<a name="line.1853"></a>
<span class="sourceLineNo">1854</span>     * @since 2.1<a name="line.1854"></a>
<span class="sourceLineNo">1855</span>     */<a name="line.1855"></a>
<span class="sourceLineNo">1856</span>    public void setDisconnectionSqlCodes(final Collection&lt;String&gt; disconnectionSqlCodes) {<a name="line.1856"></a>
<span class="sourceLineNo">1857</span>        if (disconnectionSqlCodes != null &amp;&amp; !disconnectionSqlCodes.isEmpty()) {<a name="line.1857"></a>
<span class="sourceLineNo">1858</span>            HashSet&lt;String&gt; newVal = null;<a name="line.1858"></a>
<span class="sourceLineNo">1859</span>            for (final String s : disconnectionSqlCodes) {<a name="line.1859"></a>
<span class="sourceLineNo">1860</span>                if (!isEmpty(s)) {<a name="line.1860"></a>
<span class="sourceLineNo">1861</span>                    if (newVal == null) {<a name="line.1861"></a>
<span class="sourceLineNo">1862</span>                        newVal = new HashSet&lt;&gt;();<a name="line.1862"></a>
<span class="sourceLineNo">1863</span>                    }<a name="line.1863"></a>
<span class="sourceLineNo">1864</span>                    newVal.add(s);<a name="line.1864"></a>
<span class="sourceLineNo">1865</span>                }<a name="line.1865"></a>
<span class="sourceLineNo">1866</span>            }<a name="line.1866"></a>
<span class="sourceLineNo">1867</span>            this.disconnectionSqlCodes = newVal;<a name="line.1867"></a>
<span class="sourceLineNo">1868</span>        } else {<a name="line.1868"></a>
<span class="sourceLineNo">1869</span>            this.disconnectionSqlCodes = null;<a name="line.1869"></a>
<span class="sourceLineNo">1870</span>        }<a name="line.1870"></a>
<span class="sourceLineNo">1871</span>    }<a name="line.1871"></a>
<span class="sourceLineNo">1872</span><a name="line.1872"></a>
<span class="sourceLineNo">1873</span>    /**<a name="line.1873"></a>
<span class="sourceLineNo">1874</span>     * Sets the JDBC Driver instance to use for this pool.<a name="line.1874"></a>
<span class="sourceLineNo">1875</span>     * &lt;p&gt;<a name="line.1875"></a>
<span class="sourceLineNo">1876</span>     * Note: this method currently has no effect once the pool has been initialized. The pool is initialized the first<a name="line.1876"></a>
<span class="sourceLineNo">1877</span>     * time one of the following methods is invoked: &lt;code&gt;getConnection, setLogwriter,<a name="line.1877"></a>
<span class="sourceLineNo">1878</span>     * setLoginTimeout, getLoginTimeout, getLogWriter.&lt;/code&gt;<a name="line.1878"></a>
<span class="sourceLineNo">1879</span>     * &lt;/p&gt;<a name="line.1879"></a>
<span class="sourceLineNo">1880</span>     *<a name="line.1880"></a>
<span class="sourceLineNo">1881</span>     * @param driver The JDBC Driver instance to use for this pool.<a name="line.1881"></a>
<span class="sourceLineNo">1882</span>     */<a name="line.1882"></a>
<span class="sourceLineNo">1883</span>    public synchronized void setDriver(final Driver driver) {<a name="line.1883"></a>
<span class="sourceLineNo">1884</span>        this.driver = driver;<a name="line.1884"></a>
<span class="sourceLineNo">1885</span>    }<a name="line.1885"></a>
<span class="sourceLineNo">1886</span><a name="line.1886"></a>
<span class="sourceLineNo">1887</span>    /**<a name="line.1887"></a>
<span class="sourceLineNo">1888</span>     * &lt;p&gt;<a name="line.1888"></a>
<span class="sourceLineNo">1889</span>     * Sets the class loader to be used to load the JDBC driver.<a name="line.1889"></a>
<span class="sourceLineNo">1890</span>     * &lt;/p&gt;<a name="line.1890"></a>
<span class="sourceLineNo">1891</span>     * &lt;p&gt;<a name="line.1891"></a>
<span class="sourceLineNo">1892</span>     * Note: this method currently has no effect once the pool has been initialized. The pool is initialized the first<a name="line.1892"></a>
<span class="sourceLineNo">1893</span>     * time one of the following methods is invoked: &lt;code&gt;getConnection, setLogwriter,<a name="line.1893"></a>
<span class="sourceLineNo">1894</span>     * setLoginTimeout, getLoginTimeout, getLogWriter.&lt;/code&gt;<a name="line.1894"></a>
<span class="sourceLineNo">1895</span>     * &lt;/p&gt;<a name="line.1895"></a>
<span class="sourceLineNo">1896</span>     *<a name="line.1896"></a>
<span class="sourceLineNo">1897</span>     * @param driverClassLoader the class loader with which to load the JDBC driver<a name="line.1897"></a>
<span class="sourceLineNo">1898</span>     */<a name="line.1898"></a>
<span class="sourceLineNo">1899</span>    public synchronized void setDriverClassLoader(final ClassLoader driverClassLoader) {<a name="line.1899"></a>
<span class="sourceLineNo">1900</span>        this.driverClassLoader = driverClassLoader;<a name="line.1900"></a>
<span class="sourceLineNo">1901</span>    }<a name="line.1901"></a>
<span class="sourceLineNo">1902</span><a name="line.1902"></a>
<span class="sourceLineNo">1903</span>    /**<a name="line.1903"></a>
<span class="sourceLineNo">1904</span>     * &lt;p&gt;<a name="line.1904"></a>
<span class="sourceLineNo">1905</span>     * Sets the JDBC driver class name.<a name="line.1905"></a>
<span class="sourceLineNo">1906</span>     * &lt;/p&gt;<a name="line.1906"></a>
<span class="sourceLineNo">1907</span>     * &lt;p&gt;<a name="line.1907"></a>
<span class="sourceLineNo">1908</span>     * Note: this method currently has no effect once the pool has been initialized. The pool is initialized the first<a name="line.1908"></a>
<span class="sourceLineNo">1909</span>     * time one of the following methods is invoked: &lt;code&gt;getConnection, setLogwriter,<a name="line.1909"></a>
<span class="sourceLineNo">1910</span>     * setLoginTimeout, getLoginTimeout, getLogWriter.&lt;/code&gt;<a name="line.1910"></a>
<span class="sourceLineNo">1911</span>     * &lt;/p&gt;<a name="line.1911"></a>
<span class="sourceLineNo">1912</span>     *<a name="line.1912"></a>
<span class="sourceLineNo">1913</span>     * @param driverClassName the class name of the JDBC driver<a name="line.1913"></a>
<span class="sourceLineNo">1914</span>     */<a name="line.1914"></a>
<span class="sourceLineNo">1915</span>    public synchronized void setDriverClassName(final String driverClassName) {<a name="line.1915"></a>
<span class="sourceLineNo">1916</span>        this.driverClassName = isEmpty(driverClassName) ? null : driverClassName;<a name="line.1916"></a>
<span class="sourceLineNo">1917</span>    }<a name="line.1917"></a>
<span class="sourceLineNo">1918</span><a name="line.1918"></a>
<span class="sourceLineNo">1919</span>    /**<a name="line.1919"></a>
<span class="sourceLineNo">1920</span>     * Sets the value of the flag that controls whether or not connections being returned to the pool will be checked<a name="line.1920"></a>
<span class="sourceLineNo">1921</span>     * and configured with {@link Connection#setAutoCommit(boolean) Connection.setAutoCommit(true)} if the auto commit<a name="line.1921"></a>
<span class="sourceLineNo">1922</span>     * setting is {@code false} when the connection is returned. It is &lt;code&gt;true&lt;/code&gt; by default.<a name="line.1922"></a>
<span class="sourceLineNo">1923</span>     *<a name="line.1923"></a>
<span class="sourceLineNo">1924</span>     * @param autoCommitOnReturn Whether or not connections being returned to the pool will be checked and configured<a name="line.1924"></a>
<span class="sourceLineNo">1925</span>     *                           with auto-commit.<a name="line.1925"></a>
<span class="sourceLineNo">1926</span>     * @deprecated Use {@link #setAutoCommitOnReturn(boolean)}.<a name="line.1926"></a>
<span class="sourceLineNo">1927</span>     */<a name="line.1927"></a>
<span class="sourceLineNo">1928</span>    @Deprecated<a name="line.1928"></a>
<span class="sourceLineNo">1929</span>    public void setEnableAutoCommitOnReturn(final boolean autoCommitOnReturn) {<a name="line.1929"></a>
<span class="sourceLineNo">1930</span>        this.autoCommitOnReturn = autoCommitOnReturn;<a name="line.1930"></a>
<span class="sourceLineNo">1931</span>    }<a name="line.1931"></a>
<span class="sourceLineNo">1932</span><a name="line.1932"></a>
<span class="sourceLineNo">1933</span>    /**<a name="line.1933"></a>
<span class="sourceLineNo">1934</span>     * Sets the EvictionPolicy implementation to use with this connection pool.<a name="line.1934"></a>
<span class="sourceLineNo">1935</span>     *<a name="line.1935"></a>
<span class="sourceLineNo">1936</span>     * @param evictionPolicyClassName The fully qualified class name of the EvictionPolicy implementation<a name="line.1936"></a>
<span class="sourceLineNo">1937</span>     */<a name="line.1937"></a>
<span class="sourceLineNo">1938</span>    public synchronized void setEvictionPolicyClassName(final String evictionPolicyClassName) {<a name="line.1938"></a>
<span class="sourceLineNo">1939</span>        if (connectionPool != null) {<a name="line.1939"></a>
<span class="sourceLineNo">1940</span>            connectionPool.setEvictionPolicyClassName(evictionPolicyClassName);<a name="line.1940"></a>
<span class="sourceLineNo">1941</span>        }<a name="line.1941"></a>
<span class="sourceLineNo">1942</span>        this.evictionPolicyClassName = evictionPolicyClassName;<a name="line.1942"></a>
<span class="sourceLineNo">1943</span>    }<a name="line.1943"></a>
<span class="sourceLineNo">1944</span><a name="line.1944"></a>
<span class="sourceLineNo">1945</span>    /**<a name="line.1945"></a>
<span class="sourceLineNo">1946</span>     * @see #getFastFailValidation()<a name="line.1946"></a>
<span class="sourceLineNo">1947</span>     * @param fastFailValidation true means connections created by this factory will fast fail validation<a name="line.1947"></a>
<span class="sourceLineNo">1948</span>     * @since 2.1<a name="line.1948"></a>
<span class="sourceLineNo">1949</span>     */<a name="line.1949"></a>
<span class="sourceLineNo">1950</span>    public void setFastFailValidation(final boolean fastFailValidation) {<a name="line.1950"></a>
<span class="sourceLineNo">1951</span>        this.fastFailValidation = fastFailValidation;<a name="line.1951"></a>
<span class="sourceLineNo">1952</span>    }<a name="line.1952"></a>
<span class="sourceLineNo">1953</span><a name="line.1953"></a>
<span class="sourceLineNo">1954</span>    /**<a name="line.1954"></a>
<span class="sourceLineNo">1955</span>     * &lt;p&gt;<a name="line.1955"></a>
<span class="sourceLineNo">1956</span>     * Sets the initial size of the connection pool.<a name="line.1956"></a>
<span class="sourceLineNo">1957</span>     * &lt;/p&gt;<a name="line.1957"></a>
<span class="sourceLineNo">1958</span>     * &lt;p&gt;<a name="line.1958"></a>
<span class="sourceLineNo">1959</span>     * Note: this method currently has no effect once the pool has been initialized. The pool is initialized the first<a name="line.1959"></a>
<span class="sourceLineNo">1960</span>     * time one of the following methods is invoked: &lt;code&gt;getConnection, setLogwriter,<a name="line.1960"></a>
<span class="sourceLineNo">1961</span>     * setLoginTimeout, getLoginTimeout, getLogWriter.&lt;/code&gt;<a name="line.1961"></a>
<span class="sourceLineNo">1962</span>     * &lt;/p&gt;<a name="line.1962"></a>
<span class="sourceLineNo">1963</span>     *<a name="line.1963"></a>
<span class="sourceLineNo">1964</span>     * @param initialSize the number of connections created when the pool is initialized<a name="line.1964"></a>
<span class="sourceLineNo">1965</span>     */<a name="line.1965"></a>
<span class="sourceLineNo">1966</span>    public synchronized void setInitialSize(final int initialSize) {<a name="line.1966"></a>
<span class="sourceLineNo">1967</span>        this.initialSize = initialSize;<a name="line.1967"></a>
<span class="sourceLineNo">1968</span>    }<a name="line.1968"></a>
<span class="sourceLineNo">1969</span><a name="line.1969"></a>
<span class="sourceLineNo">1970</span>    /**<a name="line.1970"></a>
<span class="sourceLineNo">1971</span>     * Sets the JMX name that has been requested for this DataSource. If the requested name is not valid, an alternative<a name="line.1971"></a>
<span class="sourceLineNo">1972</span>     * may be chosen. This DataSource will attempt to register itself using this name. If another component registers<a name="line.1972"></a>
<span class="sourceLineNo">1973</span>     * this DataSource with JMX and this name is valid this name will be used in preference to any specified by the<a name="line.1973"></a>
<span class="sourceLineNo">1974</span>     * other component.<a name="line.1974"></a>
<span class="sourceLineNo">1975</span>     *<a name="line.1975"></a>
<span class="sourceLineNo">1976</span>     * @param jmxName The JMX name that has been requested for this DataSource<a name="line.1976"></a>
<span class="sourceLineNo">1977</span>     */<a name="line.1977"></a>
<span class="sourceLineNo">1978</span>    public void setJmxName(final String jmxName) {<a name="line.1978"></a>
<span class="sourceLineNo">1979</span>        this.jmxName = jmxName;<a name="line.1979"></a>
<span class="sourceLineNo">1980</span>    }<a name="line.1980"></a>
<span class="sourceLineNo">1981</span><a name="line.1981"></a>
<span class="sourceLineNo">1982</span>    /**<a name="line.1982"></a>
<span class="sourceLineNo">1983</span>     * Sets the LIFO property. True means the pool behaves as a LIFO queue; false means FIFO.<a name="line.1983"></a>
<span class="sourceLineNo">1984</span>     *<a name="line.1984"></a>
<span class="sourceLineNo">1985</span>     * @param lifo the new value for the LIFO property<a name="line.1985"></a>
<span class="sourceLineNo">1986</span>     */<a name="line.1986"></a>
<span class="sourceLineNo">1987</span>    public synchronized void setLifo(final boolean lifo) {<a name="line.1987"></a>
<span class="sourceLineNo">1988</span>        this.lifo = lifo;<a name="line.1988"></a>
<span class="sourceLineNo">1989</span>        if (connectionPool != null) {<a name="line.1989"></a>
<span class="sourceLineNo">1990</span>            connectionPool.setLifo(lifo);<a name="line.1990"></a>
<span class="sourceLineNo">1991</span>        }<a name="line.1991"></a>
<span class="sourceLineNo">1992</span>    }<a name="line.1992"></a>
<span class="sourceLineNo">1993</span><a name="line.1993"></a>
<span class="sourceLineNo">1994</span>    /**<a name="line.1994"></a>
<span class="sourceLineNo">1995</span>     * @param logAbandoned new logAbandoned property value<a name="line.1995"></a>
<span class="sourceLineNo">1996</span>     */<a name="line.1996"></a>
<span class="sourceLineNo">1997</span>    public void setLogAbandoned(final boolean logAbandoned) {<a name="line.1997"></a>
<span class="sourceLineNo">1998</span>        if (abandonedConfig == null) {<a name="line.1998"></a>
<span class="sourceLineNo">1999</span>            abandonedConfig = new AbandonedConfig();<a name="line.1999"></a>
<span class="sourceLineNo">2000</span>        }<a name="line.2000"></a>
<span class="sourceLineNo">2001</span>        abandonedConfig.setLogAbandoned(logAbandoned);<a name="line.2001"></a>
<span class="sourceLineNo">2002</span>        final GenericObjectPool&lt;?&gt; gop = this.connectionPool;<a name="line.2002"></a>
<span class="sourceLineNo">2003</span>        if (gop != null) {<a name="line.2003"></a>
<span class="sourceLineNo">2004</span>            gop.setAbandonedConfig(abandonedConfig);<a name="line.2004"></a>
<span class="sourceLineNo">2005</span>        }<a name="line.2005"></a>
<span class="sourceLineNo">2006</span>    }<a name="line.2006"></a>
<span class="sourceLineNo">2007</span><a name="line.2007"></a>
<span class="sourceLineNo">2008</span>    /**<a name="line.2008"></a>
<span class="sourceLineNo">2009</span>     * When {@link #getMaxConnLifetimeMillis()} is set to limit connection lifetime, this property determines whether or<a name="line.2009"></a>
<span class="sourceLineNo">2010</span>     * not log messages are generated when the pool closes connections due to maximum lifetime exceeded. Set this<a name="line.2010"></a>
<span class="sourceLineNo">2011</span>     * property to false to suppress log messages when connections expire.<a name="line.2011"></a>
<span class="sourceLineNo">2012</span>     *<a name="line.2012"></a>
<span class="sourceLineNo">2013</span>     * @param logExpiredConnections Whether or not log messages are generated when the pool closes connections due to<a name="line.2013"></a>
<span class="sourceLineNo">2014</span>     *                              maximum lifetime exceeded.<a name="line.2014"></a>
<span class="sourceLineNo">2015</span>     */<a name="line.2015"></a>
<span class="sourceLineNo">2016</span>    public void setLogExpiredConnections(final boolean logExpiredConnections) {<a name="line.2016"></a>
<span class="sourceLineNo">2017</span>        this.logExpiredConnections = logExpiredConnections;<a name="line.2017"></a>
<span class="sourceLineNo">2018</span>    }<a name="line.2018"></a>
<span class="sourceLineNo">2019</span><a name="line.2019"></a>
<span class="sourceLineNo">2020</span>    /**<a name="line.2020"></a>
<span class="sourceLineNo">2021</span>     * &lt;strong&gt;BasicDataSource does NOT support this method. &lt;/strong&gt;<a name="line.2021"></a>
<span class="sourceLineNo">2022</span>     *<a name="line.2022"></a>
<span class="sourceLineNo">2023</span>     * &lt;p&gt;<a name="line.2023"></a>
<span class="sourceLineNo">2024</span>     * Set the login timeout (in seconds) for connecting to the database.<a name="line.2024"></a>
<span class="sourceLineNo">2025</span>     * &lt;/p&gt;<a name="line.2025"></a>
<span class="sourceLineNo">2026</span>     * &lt;p&gt;<a name="line.2026"></a>
<span class="sourceLineNo">2027</span>     * Calls {@link #createDataSource()}, so has the side effect of initializing the connection pool.<a name="line.2027"></a>
<span class="sourceLineNo">2028</span>     * &lt;/p&gt;<a name="line.2028"></a>
<span class="sourceLineNo">2029</span>     *<a name="line.2029"></a>
<span class="sourceLineNo">2030</span>     * @param loginTimeout The new login timeout, or zero for no timeout<a name="line.2030"></a>
<span class="sourceLineNo">2031</span>     * @throws UnsupportedOperationException If the DataSource implementation does not support the login timeout<a name="line.2031"></a>
<span class="sourceLineNo">2032</span>     *                                       feature.<a name="line.2032"></a>
<span class="sourceLineNo">2033</span>     * @throws SQLException                  if a database access error occurs<a name="line.2033"></a>
<span class="sourceLineNo">2034</span>     */<a name="line.2034"></a>
<span class="sourceLineNo">2035</span>    @Override<a name="line.2035"></a>
<span class="sourceLineNo">2036</span>    public void setLoginTimeout(final int loginTimeout) throws SQLException {<a name="line.2036"></a>
<span class="sourceLineNo">2037</span>        // This method isn't supported by the PoolingDataSource returned by the<a name="line.2037"></a>
<span class="sourceLineNo">2038</span>        // createDataSource<a name="line.2038"></a>
<span class="sourceLineNo">2039</span>        throw new UnsupportedOperationException("Not supported by BasicDataSource");<a name="line.2039"></a>
<span class="sourceLineNo">2040</span>    }<a name="line.2040"></a>
<span class="sourceLineNo">2041</span><a name="line.2041"></a>
<span class="sourceLineNo">2042</span>    /**<a name="line.2042"></a>
<span class="sourceLineNo">2043</span>     * &lt;p&gt;<a name="line.2043"></a>
<span class="sourceLineNo">2044</span>     * Sets the log writer being used by this data source.<a name="line.2044"></a>
<span class="sourceLineNo">2045</span>     * &lt;/p&gt;<a name="line.2045"></a>
<span class="sourceLineNo">2046</span>     * &lt;p&gt;<a name="line.2046"></a>
<span class="sourceLineNo">2047</span>     * Calls {@link #createDataSource()}, so has the side effect of initializing the connection pool.<a name="line.2047"></a>
<span class="sourceLineNo">2048</span>     * &lt;/p&gt;<a name="line.2048"></a>
<span class="sourceLineNo">2049</span>     *<a name="line.2049"></a>
<span class="sourceLineNo">2050</span>     * @param logWriter The new log writer<a name="line.2050"></a>
<span class="sourceLineNo">2051</span>     * @throws SQLException if a database access error occurs<a name="line.2051"></a>
<span class="sourceLineNo">2052</span>     */<a name="line.2052"></a>
<span class="sourceLineNo">2053</span>    @Override<a name="line.2053"></a>
<span class="sourceLineNo">2054</span>    public void setLogWriter(final PrintWriter logWriter) throws SQLException {<a name="line.2054"></a>
<span class="sourceLineNo">2055</span>        createDataSource().setLogWriter(logWriter);<a name="line.2055"></a>
<span class="sourceLineNo">2056</span>        this.logWriter = logWriter;<a name="line.2056"></a>
<span class="sourceLineNo">2057</span>    }<a name="line.2057"></a>
<span class="sourceLineNo">2058</span><a name="line.2058"></a>
<span class="sourceLineNo">2059</span>    /**<a name="line.2059"></a>
<span class="sourceLineNo">2060</span>     * &lt;p&gt;<a name="line.2060"></a>
<span class="sourceLineNo">2061</span>     * Sets the maximum permitted lifetime of a connection in milliseconds. A value of zero or less indicates an<a name="line.2061"></a>
<span class="sourceLineNo">2062</span>     * infinite lifetime.<a name="line.2062"></a>
<span class="sourceLineNo">2063</span>     * &lt;/p&gt;<a name="line.2063"></a>
<span class="sourceLineNo">2064</span>     * &lt;p&gt;<a name="line.2064"></a>
<span class="sourceLineNo">2065</span>     * Note: this method currently has no effect once the pool has been initialized. The pool is initialized the first<a name="line.2065"></a>
<span class="sourceLineNo">2066</span>     * time one of the following methods is invoked: &lt;code&gt;getConnection, setLogwriter,<a name="line.2066"></a>
<span class="sourceLineNo">2067</span>     * setLoginTimeout, getLoginTimeout, getLogWriter.&lt;/code&gt;<a name="line.2067"></a>
<span class="sourceLineNo">2068</span>     * &lt;/p&gt;<a name="line.2068"></a>
<span class="sourceLineNo">2069</span>     *<a name="line.2069"></a>
<span class="sourceLineNo">2070</span>     * @param maxConnLifetimeMillis The maximum permitted lifetime of a connection in milliseconds.<a name="line.2070"></a>
<span class="sourceLineNo">2071</span>     */<a name="line.2071"></a>
<span class="sourceLineNo">2072</span>    public void setMaxConnLifetimeMillis(final long maxConnLifetimeMillis) {<a name="line.2072"></a>
<span class="sourceLineNo">2073</span>        this.maxConnLifetimeMillis = maxConnLifetimeMillis;<a name="line.2073"></a>
<span class="sourceLineNo">2074</span>    }<a name="line.2074"></a>
<span class="sourceLineNo">2075</span><a name="line.2075"></a>
<span class="sourceLineNo">2076</span>    /**<a name="line.2076"></a>
<span class="sourceLineNo">2077</span>     * Sets the maximum number of connections that can remain idle in the pool. Excess idle connections are destroyed on<a name="line.2077"></a>
<span class="sourceLineNo">2078</span>     * return to the pool.<a name="line.2078"></a>
<span class="sourceLineNo">2079</span>     *<a name="line.2079"></a>
<span class="sourceLineNo">2080</span>     * @see #getMaxIdle()<a name="line.2080"></a>
<span class="sourceLineNo">2081</span>     * @param maxIdle the new value for maxIdle<a name="line.2081"></a>
<span class="sourceLineNo">2082</span>     */<a name="line.2082"></a>
<span class="sourceLineNo">2083</span>    public synchronized void setMaxIdle(final int maxIdle) {<a name="line.2083"></a>
<span class="sourceLineNo">2084</span>        this.maxIdle = maxIdle;<a name="line.2084"></a>
<span class="sourceLineNo">2085</span>        if (connectionPool != null) {<a name="line.2085"></a>
<span class="sourceLineNo">2086</span>            connectionPool.setMaxIdle(maxIdle);<a name="line.2086"></a>
<span class="sourceLineNo">2087</span>        }<a name="line.2087"></a>
<span class="sourceLineNo">2088</span>    }<a name="line.2088"></a>
<span class="sourceLineNo">2089</span><a name="line.2089"></a>
<span class="sourceLineNo">2090</span>    /**<a name="line.2090"></a>
<span class="sourceLineNo">2091</span>     * &lt;p&gt;<a name="line.2091"></a>
<span class="sourceLineNo">2092</span>     * Sets the value of the &lt;code&gt;maxOpenPreparedStatements&lt;/code&gt; property.<a name="line.2092"></a>
<span class="sourceLineNo">2093</span>     * &lt;/p&gt;<a name="line.2093"></a>
<span class="sourceLineNo">2094</span>     * &lt;p&gt;<a name="line.2094"></a>
<span class="sourceLineNo">2095</span>     * Note: this method currently has no effect once the pool has been initialized. The pool is initialized the first<a name="line.2095"></a>
<span class="sourceLineNo">2096</span>     * time one of the following methods is invoked: &lt;code&gt;getConnection, setLogwriter,<a name="line.2096"></a>
<span class="sourceLineNo">2097</span>     * setLoginTimeout, getLoginTimeout, getLogWriter.&lt;/code&gt;<a name="line.2097"></a>
<span class="sourceLineNo">2098</span>     * &lt;/p&gt;<a name="line.2098"></a>
<span class="sourceLineNo">2099</span>     *<a name="line.2099"></a>
<span class="sourceLineNo">2100</span>     * @param maxOpenStatements the new maximum number of prepared statements<a name="line.2100"></a>
<span class="sourceLineNo">2101</span>     */<a name="line.2101"></a>
<span class="sourceLineNo">2102</span>    public synchronized void setMaxOpenPreparedStatements(final int maxOpenStatements) {<a name="line.2102"></a>
<span class="sourceLineNo">2103</span>        this.maxOpenPreparedStatements = maxOpenStatements;<a name="line.2103"></a>
<span class="sourceLineNo">2104</span>    }<a name="line.2104"></a>
<span class="sourceLineNo">2105</span><a name="line.2105"></a>
<span class="sourceLineNo">2106</span>    /**<a name="line.2106"></a>
<span class="sourceLineNo">2107</span>     * Sets the maximum total number of idle and borrows connections that can be active at the same time. Use a negative<a name="line.2107"></a>
<span class="sourceLineNo">2108</span>     * value for no limit.<a name="line.2108"></a>
<span class="sourceLineNo">2109</span>     *<a name="line.2109"></a>
<span class="sourceLineNo">2110</span>     * @param maxTotal the new value for maxTotal<a name="line.2110"></a>
<span class="sourceLineNo">2111</span>     * @see #getMaxTotal()<a name="line.2111"></a>
<span class="sourceLineNo">2112</span>     */<a name="line.2112"></a>
<span class="sourceLineNo">2113</span>    public synchronized void setMaxTotal(final int maxTotal) {<a name="line.2113"></a>
<span class="sourceLineNo">2114</span>        this.maxTotal = maxTotal;<a name="line.2114"></a>
<span class="sourceLineNo">2115</span>        if (connectionPool != null) {<a name="line.2115"></a>
<span class="sourceLineNo">2116</span>            connectionPool.setMaxTotal(maxTotal);<a name="line.2116"></a>
<span class="sourceLineNo">2117</span>        }<a name="line.2117"></a>
<span class="sourceLineNo">2118</span>    }<a name="line.2118"></a>
<span class="sourceLineNo">2119</span><a name="line.2119"></a>
<span class="sourceLineNo">2120</span>    /**<a name="line.2120"></a>
<span class="sourceLineNo">2121</span>     * Sets the MaxWaitMillis property. Use -1 to make the pool wait indefinitely.<a name="line.2121"></a>
<span class="sourceLineNo">2122</span>     *<a name="line.2122"></a>
<span class="sourceLineNo">2123</span>     * @param maxWaitMillis the new value for MaxWaitMillis<a name="line.2123"></a>
<span class="sourceLineNo">2124</span>     * @see #getMaxWaitMillis()<a name="line.2124"></a>
<span class="sourceLineNo">2125</span>     */<a name="line.2125"></a>
<span class="sourceLineNo">2126</span>    public synchronized void setMaxWaitMillis(final long maxWaitMillis) {<a name="line.2126"></a>
<span class="sourceLineNo">2127</span>        this.maxWaitMillis = maxWaitMillis;<a name="line.2127"></a>
<span class="sourceLineNo">2128</span>        if (connectionPool != null) {<a name="line.2128"></a>
<span class="sourceLineNo">2129</span>            connectionPool.setMaxWaitMillis(maxWaitMillis);<a name="line.2129"></a>
<span class="sourceLineNo">2130</span>        }<a name="line.2130"></a>
<span class="sourceLineNo">2131</span>    }<a name="line.2131"></a>
<span class="sourceLineNo">2132</span><a name="line.2132"></a>
<span class="sourceLineNo">2133</span>    // ------------------------------------------------------ Protected Methods<a name="line.2133"></a>
<span class="sourceLineNo">2134</span><a name="line.2134"></a>
<span class="sourceLineNo">2135</span>    /**<a name="line.2135"></a>
<span class="sourceLineNo">2136</span>     * Sets the {@link #minEvictableIdleTimeMillis} property.<a name="line.2136"></a>
<span class="sourceLineNo">2137</span>     *<a name="line.2137"></a>
<span class="sourceLineNo">2138</span>     * @param minEvictableIdleTimeMillis the minimum amount of time an object may sit idle in the pool<a name="line.2138"></a>
<span class="sourceLineNo">2139</span>     * @see #minEvictableIdleTimeMillis<a name="line.2139"></a>
<span class="sourceLineNo">2140</span>     */<a name="line.2140"></a>
<span class="sourceLineNo">2141</span>    public synchronized void setMinEvictableIdleTimeMillis(final long minEvictableIdleTimeMillis) {<a name="line.2141"></a>
<span class="sourceLineNo">2142</span>        this.minEvictableIdleTimeMillis = minEvictableIdleTimeMillis;<a name="line.2142"></a>
<span class="sourceLineNo">2143</span>        if (connectionPool != null) {<a name="line.2143"></a>
<span class="sourceLineNo">2144</span>            connectionPool.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);<a name="line.2144"></a>
<span class="sourceLineNo">2145</span>        }<a name="line.2145"></a>
<span class="sourceLineNo">2146</span>    }<a name="line.2146"></a>
<span class="sourceLineNo">2147</span><a name="line.2147"></a>
<span class="sourceLineNo">2148</span>    /**<a name="line.2148"></a>
<span class="sourceLineNo">2149</span>     * Sets the minimum number of idle connections in the pool. The pool attempts to ensure that minIdle connections are<a name="line.2149"></a>
<span class="sourceLineNo">2150</span>     * available when the idle object evictor runs. The value of this property has no effect unless<a name="line.2150"></a>
<span class="sourceLineNo">2151</span>     * {@link #timeBetweenEvictionRunsMillis} has a positive value.<a name="line.2151"></a>
<span class="sourceLineNo">2152</span>     *<a name="line.2152"></a>
<span class="sourceLineNo">2153</span>     * @param minIdle the new value for minIdle<a name="line.2153"></a>
<span class="sourceLineNo">2154</span>     * @see GenericObjectPool#setMinIdle(int)<a name="line.2154"></a>
<span class="sourceLineNo">2155</span>     */<a name="line.2155"></a>
<span class="sourceLineNo">2156</span>    public synchronized void setMinIdle(final int minIdle) {<a name="line.2156"></a>
<span class="sourceLineNo">2157</span>        this.minIdle = minIdle;<a name="line.2157"></a>
<span class="sourceLineNo">2158</span>        if (connectionPool != null) {<a name="line.2158"></a>
<span class="sourceLineNo">2159</span>            connectionPool.setMinIdle(minIdle);<a name="line.2159"></a>
<span class="sourceLineNo">2160</span>        }<a name="line.2160"></a>
<span class="sourceLineNo">2161</span>    }<a name="line.2161"></a>
<span class="sourceLineNo">2162</span><a name="line.2162"></a>
<span class="sourceLineNo">2163</span>    /**<a name="line.2163"></a>
<span class="sourceLineNo">2164</span>     * Sets the value of the {@link #numTestsPerEvictionRun} property.<a name="line.2164"></a>
<span class="sourceLineNo">2165</span>     *<a name="line.2165"></a>
<span class="sourceLineNo">2166</span>     * @param numTestsPerEvictionRun the new {@link #numTestsPerEvictionRun} value<a name="line.2166"></a>
<span class="sourceLineNo">2167</span>     * @see #numTestsPerEvictionRun<a name="line.2167"></a>
<span class="sourceLineNo">2168</span>     */<a name="line.2168"></a>
<span class="sourceLineNo">2169</span>    public synchronized void setNumTestsPerEvictionRun(final int numTestsPerEvictionRun) {<a name="line.2169"></a>
<span class="sourceLineNo">2170</span>        this.numTestsPerEvictionRun = numTestsPerEvictionRun;<a name="line.2170"></a>
<span class="sourceLineNo">2171</span>        if (connectionPool != null) {<a name="line.2171"></a>
<span class="sourceLineNo">2172</span>            connectionPool.setNumTestsPerEvictionRun(numTestsPerEvictionRun);<a name="line.2172"></a>
<span class="sourceLineNo">2173</span>        }<a name="line.2173"></a>
<span class="sourceLineNo">2174</span>    }<a name="line.2174"></a>
<span class="sourceLineNo">2175</span><a name="line.2175"></a>
<span class="sourceLineNo">2176</span>    /**<a name="line.2176"></a>
<span class="sourceLineNo">2177</span>     * &lt;p&gt;<a name="line.2177"></a>
<span class="sourceLineNo">2178</span>     * Sets the {@link #password}.<a name="line.2178"></a>
<span class="sourceLineNo">2179</span>     * &lt;/p&gt;<a name="line.2179"></a>
<span class="sourceLineNo">2180</span>     * &lt;p&gt;<a name="line.2180"></a>
<span class="sourceLineNo">2181</span>     * Note: this method currently has no effect once the pool has been initialized. The pool is initialized the first<a name="line.2181"></a>
<span class="sourceLineNo">2182</span>     * time one of the following methods is invoked: &lt;code&gt;getConnection, setLogwriter,<a name="line.2182"></a>
<span class="sourceLineNo">2183</span>     * setLoginTimeout, getLoginTimeout, getLogWriter.&lt;/code&gt;<a name="line.2183"></a>
<span class="sourceLineNo">2184</span>     * &lt;/p&gt;<a name="line.2184"></a>
<span class="sourceLineNo">2185</span>     *<a name="line.2185"></a>
<span class="sourceLineNo">2186</span>     * @param password new value for the password<a name="line.2186"></a>
<span class="sourceLineNo">2187</span>     */<a name="line.2187"></a>
<span class="sourceLineNo">2188</span>    public void setPassword(final String password) {<a name="line.2188"></a>
<span class="sourceLineNo">2189</span>        this.password = password;<a name="line.2189"></a>
<span class="sourceLineNo">2190</span>    }<a name="line.2190"></a>
<span class="sourceLineNo">2191</span><a name="line.2191"></a>
<span class="sourceLineNo">2192</span>    /**<a name="line.2192"></a>
<span class="sourceLineNo">2193</span>     * &lt;p&gt;<a name="line.2193"></a>
<span class="sourceLineNo">2194</span>     * Sets whether to pool statements or not.<a name="line.2194"></a>
<span class="sourceLineNo">2195</span>     * &lt;/p&gt;<a name="line.2195"></a>
<span class="sourceLineNo">2196</span>     * &lt;p&gt;<a name="line.2196"></a>
<span class="sourceLineNo">2197</span>     * Note: this method currently has no effect once the pool has been initialized. The pool is initialized the first<a name="line.2197"></a>
<span class="sourceLineNo">2198</span>     * time one of the following methods is invoked: &lt;code&gt;getConnection, setLogwriter,<a name="line.2198"></a>
<span class="sourceLineNo">2199</span>     * setLoginTimeout, getLoginTimeout, getLogWriter.&lt;/code&gt;<a name="line.2199"></a>
<span class="sourceLineNo">2200</span>     * &lt;/p&gt;<a name="line.2200"></a>
<span class="sourceLineNo">2201</span>     *<a name="line.2201"></a>
<span class="sourceLineNo">2202</span>     * @param poolingStatements pooling on or off<a name="line.2202"></a>
<span class="sourceLineNo">2203</span>     */<a name="line.2203"></a>
<span class="sourceLineNo">2204</span>    public synchronized void setPoolPreparedStatements(final boolean poolingStatements) {<a name="line.2204"></a>
<span class="sourceLineNo">2205</span>        this.poolPreparedStatements = poolingStatements;<a name="line.2205"></a>
<span class="sourceLineNo">2206</span>    }<a name="line.2206"></a>
<span class="sourceLineNo">2207</span><a name="line.2207"></a>
<span class="sourceLineNo">2208</span>    /**<a name="line.2208"></a>
<span class="sourceLineNo">2209</span>     * @param removeAbandonedOnBorrow true means abandoned connections may be removed when connections are borrowed from<a name="line.2209"></a>
<span class="sourceLineNo">2210</span>     *                                the pool.<a name="line.2210"></a>
<span class="sourceLineNo">2211</span>     * @see #getRemoveAbandonedOnBorrow()<a name="line.2211"></a>
<span class="sourceLineNo">2212</span>     */<a name="line.2212"></a>
<span class="sourceLineNo">2213</span>    public void setRemoveAbandonedOnBorrow(final boolean removeAbandonedOnBorrow) {<a name="line.2213"></a>
<span class="sourceLineNo">2214</span>        if (abandonedConfig == null) {<a name="line.2214"></a>
<span class="sourceLineNo">2215</span>            abandonedConfig = new AbandonedConfig();<a name="line.2215"></a>
<span class="sourceLineNo">2216</span>        }<a name="line.2216"></a>
<span class="sourceLineNo">2217</span>        abandonedConfig.setRemoveAbandonedOnBorrow(removeAbandonedOnBorrow);<a name="line.2217"></a>
<span class="sourceLineNo">2218</span>        final GenericObjectPool&lt;?&gt; gop = this.connectionPool;<a name="line.2218"></a>
<span class="sourceLineNo">2219</span>        if (gop != null) {<a name="line.2219"></a>
<span class="sourceLineNo">2220</span>            gop.setAbandonedConfig(abandonedConfig);<a name="line.2220"></a>
<span class="sourceLineNo">2221</span>        }<a name="line.2221"></a>
<span class="sourceLineNo">2222</span>    }<a name="line.2222"></a>
<span class="sourceLineNo">2223</span><a name="line.2223"></a>
<span class="sourceLineNo">2224</span>    /**<a name="line.2224"></a>
<span class="sourceLineNo">2225</span>     * @param removeAbandonedOnMaintenance true means abandoned connections may be removed on pool maintenance.<a name="line.2225"></a>
<span class="sourceLineNo">2226</span>     * @see #getRemoveAbandonedOnMaintenance()<a name="line.2226"></a>
<span class="sourceLineNo">2227</span>     */<a name="line.2227"></a>
<span class="sourceLineNo">2228</span>    public void setRemoveAbandonedOnMaintenance(final boolean removeAbandonedOnMaintenance) {<a name="line.2228"></a>
<span class="sourceLineNo">2229</span>        if (abandonedConfig == null) {<a name="line.2229"></a>
<span class="sourceLineNo">2230</span>            abandonedConfig = new AbandonedConfig();<a name="line.2230"></a>
<span class="sourceLineNo">2231</span>        }<a name="line.2231"></a>
<span class="sourceLineNo">2232</span>        abandonedConfig.setRemoveAbandonedOnMaintenance(removeAbandonedOnMaintenance);<a name="line.2232"></a>
<span class="sourceLineNo">2233</span>        final GenericObjectPool&lt;?&gt; gop = this.connectionPool;<a name="line.2233"></a>
<span class="sourceLineNo">2234</span>        if (gop != null) {<a name="line.2234"></a>
<span class="sourceLineNo">2235</span>            gop.setAbandonedConfig(abandonedConfig);<a name="line.2235"></a>
<span class="sourceLineNo">2236</span>        }<a name="line.2236"></a>
<span class="sourceLineNo">2237</span>    }<a name="line.2237"></a>
<span class="sourceLineNo">2238</span><a name="line.2238"></a>
<span class="sourceLineNo">2239</span>    /**<a name="line.2239"></a>
<span class="sourceLineNo">2240</span>     * &lt;p&gt;<a name="line.2240"></a>
<span class="sourceLineNo">2241</span>     * Sets the timeout in seconds before an abandoned connection can be removed.<a name="line.2241"></a>
<span class="sourceLineNo">2242</span>     * &lt;/p&gt;<a name="line.2242"></a>
<span class="sourceLineNo">2243</span>     *<a name="line.2243"></a>
<span class="sourceLineNo">2244</span>     * &lt;p&gt;<a name="line.2244"></a>
<span class="sourceLineNo">2245</span>     * Setting this property has no effect if {@link #getRemoveAbandonedOnBorrow()} and<a name="line.2245"></a>
<span class="sourceLineNo">2246</span>     * {@link #getRemoveAbandonedOnMaintenance()} are false.<a name="line.2246"></a>
<span class="sourceLineNo">2247</span>     * &lt;/p&gt;<a name="line.2247"></a>
<span class="sourceLineNo">2248</span>     *<a name="line.2248"></a>
<span class="sourceLineNo">2249</span>     * @param removeAbandonedTimeout new abandoned timeout in seconds<a name="line.2249"></a>
<span class="sourceLineNo">2250</span>     * @see #getRemoveAbandonedTimeout()<a name="line.2250"></a>
<span class="sourceLineNo">2251</span>     * @see #getRemoveAbandonedOnBorrow()<a name="line.2251"></a>
<span class="sourceLineNo">2252</span>     * @see #getRemoveAbandonedOnMaintenance()<a name="line.2252"></a>
<span class="sourceLineNo">2253</span>     */<a name="line.2253"></a>
<span class="sourceLineNo">2254</span>    public void setRemoveAbandonedTimeout(final int removeAbandonedTimeout) {<a name="line.2254"></a>
<span class="sourceLineNo">2255</span>        if (abandonedConfig == null) {<a name="line.2255"></a>
<span class="sourceLineNo">2256</span>            abandonedConfig = new AbandonedConfig();<a name="line.2256"></a>
<span class="sourceLineNo">2257</span>        }<a name="line.2257"></a>
<span class="sourceLineNo">2258</span>        abandonedConfig.setRemoveAbandonedTimeout(removeAbandonedTimeout);<a name="line.2258"></a>
<span class="sourceLineNo">2259</span>        final GenericObjectPool&lt;?&gt; gop = this.connectionPool;<a name="line.2259"></a>
<span class="sourceLineNo">2260</span>        if (gop != null) {<a name="line.2260"></a>
<span class="sourceLineNo">2261</span>            gop.setAbandonedConfig(abandonedConfig);<a name="line.2261"></a>
<span class="sourceLineNo">2262</span>        }<a name="line.2262"></a>
<span class="sourceLineNo">2263</span>    }<a name="line.2263"></a>
<span class="sourceLineNo">2264</span><a name="line.2264"></a>
<span class="sourceLineNo">2265</span>    /**<a name="line.2265"></a>
<span class="sourceLineNo">2266</span>     * Sets the flag that controls if a connection will be rolled back when it is returned to the pool if auto commit is<a name="line.2266"></a>
<span class="sourceLineNo">2267</span>     * not enabled and the connection is not read only.<a name="line.2267"></a>
<span class="sourceLineNo">2268</span>     *<a name="line.2268"></a>
<span class="sourceLineNo">2269</span>     * @param rollbackOnReturn whether a connection will be rolled back when it is returned to the pool.<a name="line.2269"></a>
<span class="sourceLineNo">2270</span>     */<a name="line.2270"></a>
<span class="sourceLineNo">2271</span>    public void setRollbackOnReturn(final boolean rollbackOnReturn) {<a name="line.2271"></a>
<span class="sourceLineNo">2272</span>        this.rollbackOnReturn = rollbackOnReturn;<a name="line.2272"></a>
<span class="sourceLineNo">2273</span>    }<a name="line.2273"></a>
<span class="sourceLineNo">2274</span><a name="line.2274"></a>
<span class="sourceLineNo">2275</span>    /**<a name="line.2275"></a>
<span class="sourceLineNo">2276</span>     * Sets the minimum amount of time a connection may sit idle in the pool before it is eligible for eviction by the<a name="line.2276"></a>
<span class="sourceLineNo">2277</span>     * idle object evictor, with the extra condition that at least "minIdle" connections remain in the pool.<a name="line.2277"></a>
<span class="sourceLineNo">2278</span>     *<a name="line.2278"></a>
<span class="sourceLineNo">2279</span>     * @param softMinEvictableIdleTimeMillis minimum amount of time a connection may sit idle in the pool before it is<a name="line.2279"></a>
<span class="sourceLineNo">2280</span>     *                                       eligible for eviction, assuming there are minIdle idle connections in the<a name="line.2280"></a>
<span class="sourceLineNo">2281</span>     *                                       pool.<a name="line.2281"></a>
<span class="sourceLineNo">2282</span>     * @see #getSoftMinEvictableIdleTimeMillis<a name="line.2282"></a>
<span class="sourceLineNo">2283</span>     */<a name="line.2283"></a>
<span class="sourceLineNo">2284</span>    public synchronized void setSoftMinEvictableIdleTimeMillis(final long softMinEvictableIdleTimeMillis) {<a name="line.2284"></a>
<span class="sourceLineNo">2285</span>        this.softMinEvictableIdleTimeMillis = softMinEvictableIdleTimeMillis;<a name="line.2285"></a>
<span class="sourceLineNo">2286</span>        if (connectionPool != null) {<a name="line.2286"></a>
<span class="sourceLineNo">2287</span>            connectionPool.setSoftMinEvictableIdleTimeMillis(softMinEvictableIdleTimeMillis);<a name="line.2287"></a>
<span class="sourceLineNo">2288</span>        }<a name="line.2288"></a>
<span class="sourceLineNo">2289</span>    }<a name="line.2289"></a>
<span class="sourceLineNo">2290</span><a name="line.2290"></a>
<span class="sourceLineNo">2291</span>    /**<a name="line.2291"></a>
<span class="sourceLineNo">2292</span>     * Sets the {@link #testOnBorrow} property. This property determines whether or not the pool will validate objects<a name="line.2292"></a>
<span class="sourceLineNo">2293</span>     * before they are borrowed from the pool.<a name="line.2293"></a>
<span class="sourceLineNo">2294</span>     *<a name="line.2294"></a>
<span class="sourceLineNo">2295</span>     * @param testOnBorrow new value for testOnBorrow property<a name="line.2295"></a>
<span class="sourceLineNo">2296</span>     */<a name="line.2296"></a>
<span class="sourceLineNo">2297</span>    public synchronized void setTestOnBorrow(final boolean testOnBorrow) {<a name="line.2297"></a>
<span class="sourceLineNo">2298</span>        this.testOnBorrow = testOnBorrow;<a name="line.2298"></a>
<span class="sourceLineNo">2299</span>        if (connectionPool != null) {<a name="line.2299"></a>
<span class="sourceLineNo">2300</span>            connectionPool.setTestOnBorrow(testOnBorrow);<a name="line.2300"></a>
<span class="sourceLineNo">2301</span>        }<a name="line.2301"></a>
<span class="sourceLineNo">2302</span>    }<a name="line.2302"></a>
<span class="sourceLineNo">2303</span><a name="line.2303"></a>
<span class="sourceLineNo">2304</span>    /**<a name="line.2304"></a>
<span class="sourceLineNo">2305</span>     * Sets the {@link #testOnCreate} property. This property determines whether or not the pool will validate objects<a name="line.2305"></a>
<span class="sourceLineNo">2306</span>     * immediately after they are created by the pool<a name="line.2306"></a>
<span class="sourceLineNo">2307</span>     *<a name="line.2307"></a>
<span class="sourceLineNo">2308</span>     * @param testOnCreate new value for testOnCreate property<a name="line.2308"></a>
<span class="sourceLineNo">2309</span>     */<a name="line.2309"></a>
<span class="sourceLineNo">2310</span>    public synchronized void setTestOnCreate(final boolean testOnCreate) {<a name="line.2310"></a>
<span class="sourceLineNo">2311</span>        this.testOnCreate = testOnCreate;<a name="line.2311"></a>
<span class="sourceLineNo">2312</span>        if (connectionPool != null) {<a name="line.2312"></a>
<span class="sourceLineNo">2313</span>            connectionPool.setTestOnCreate(testOnCreate);<a name="line.2313"></a>
<span class="sourceLineNo">2314</span>        }<a name="line.2314"></a>
<span class="sourceLineNo">2315</span>    }<a name="line.2315"></a>
<span class="sourceLineNo">2316</span><a name="line.2316"></a>
<span class="sourceLineNo">2317</span>    /**<a name="line.2317"></a>
<span class="sourceLineNo">2318</span>     * Sets the &lt;code&gt;testOnReturn&lt;/code&gt; property. This property determines whether or not the pool will validate<a name="line.2318"></a>
<span class="sourceLineNo">2319</span>     * objects before they are returned to the pool.<a name="line.2319"></a>
<span class="sourceLineNo">2320</span>     *<a name="line.2320"></a>
<span class="sourceLineNo">2321</span>     * @param testOnReturn new value for testOnReturn property<a name="line.2321"></a>
<span class="sourceLineNo">2322</span>     */<a name="line.2322"></a>
<span class="sourceLineNo">2323</span>    public synchronized void setTestOnReturn(final boolean testOnReturn) {<a name="line.2323"></a>
<span class="sourceLineNo">2324</span>        this.testOnReturn = testOnReturn;<a name="line.2324"></a>
<span class="sourceLineNo">2325</span>        if (connectionPool != null) {<a name="line.2325"></a>
<span class="sourceLineNo">2326</span>            connectionPool.setTestOnReturn(testOnReturn);<a name="line.2326"></a>
<span class="sourceLineNo">2327</span>        }<a name="line.2327"></a>
<span class="sourceLineNo">2328</span>    }<a name="line.2328"></a>
<span class="sourceLineNo">2329</span><a name="line.2329"></a>
<span class="sourceLineNo">2330</span>    /**<a name="line.2330"></a>
<span class="sourceLineNo">2331</span>     * Sets the &lt;code&gt;testWhileIdle&lt;/code&gt; property. This property determines whether or not the idle object evictor<a name="line.2331"></a>
<span class="sourceLineNo">2332</span>     * will validate connections.<a name="line.2332"></a>
<span class="sourceLineNo">2333</span>     *<a name="line.2333"></a>
<span class="sourceLineNo">2334</span>     * @param testWhileIdle new value for testWhileIdle property<a name="line.2334"></a>
<span class="sourceLineNo">2335</span>     */<a name="line.2335"></a>
<span class="sourceLineNo">2336</span>    public synchronized void setTestWhileIdle(final boolean testWhileIdle) {<a name="line.2336"></a>
<span class="sourceLineNo">2337</span>        this.testWhileIdle = testWhileIdle;<a name="line.2337"></a>
<span class="sourceLineNo">2338</span>        if (connectionPool != null) {<a name="line.2338"></a>
<span class="sourceLineNo">2339</span>            connectionPool.setTestWhileIdle(testWhileIdle);<a name="line.2339"></a>
<span class="sourceLineNo">2340</span>        }<a name="line.2340"></a>
<span class="sourceLineNo">2341</span>    }<a name="line.2341"></a>
<span class="sourceLineNo">2342</span><a name="line.2342"></a>
<span class="sourceLineNo">2343</span>    /**<a name="line.2343"></a>
<span class="sourceLineNo">2344</span>     * Sets the {@link #timeBetweenEvictionRunsMillis} property.<a name="line.2344"></a>
<span class="sourceLineNo">2345</span>     *<a name="line.2345"></a>
<span class="sourceLineNo">2346</span>     * @param timeBetweenEvictionRunsMillis the new time between evictor runs<a name="line.2346"></a>
<span class="sourceLineNo">2347</span>     * @see #timeBetweenEvictionRunsMillis<a name="line.2347"></a>
<span class="sourceLineNo">2348</span>     */<a name="line.2348"></a>
<span class="sourceLineNo">2349</span>    public synchronized void setTimeBetweenEvictionRunsMillis(final long timeBetweenEvictionRunsMillis) {<a name="line.2349"></a>
<span class="sourceLineNo">2350</span>        this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;<a name="line.2350"></a>
<span class="sourceLineNo">2351</span>        if (connectionPool != null) {<a name="line.2351"></a>
<span class="sourceLineNo">2352</span>            connectionPool.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);<a name="line.2352"></a>
<span class="sourceLineNo">2353</span>        }<a name="line.2353"></a>
<span class="sourceLineNo">2354</span>    }<a name="line.2354"></a>
<span class="sourceLineNo">2355</span><a name="line.2355"></a>
<span class="sourceLineNo">2356</span>    /**<a name="line.2356"></a>
<span class="sourceLineNo">2357</span>     * &lt;p&gt;<a name="line.2357"></a>
<span class="sourceLineNo">2358</span>     * Sets the {@link #url}.<a name="line.2358"></a>
<span class="sourceLineNo">2359</span>     * &lt;/p&gt;<a name="line.2359"></a>
<span class="sourceLineNo">2360</span>     * &lt;p&gt;<a name="line.2360"></a>
<span class="sourceLineNo">2361</span>     * Note: this method currently has no effect once the pool has been initialized. The pool is initialized the first<a name="line.2361"></a>
<span class="sourceLineNo">2362</span>     * time one of the following methods is invoked: &lt;code&gt;getConnection, setLogwriter,<a name="line.2362"></a>
<span class="sourceLineNo">2363</span>     * setLoginTimeout, getLoginTimeout, getLogWriter.&lt;/code&gt;<a name="line.2363"></a>
<span class="sourceLineNo">2364</span>     * &lt;/p&gt;<a name="line.2364"></a>
<span class="sourceLineNo">2365</span>     *<a name="line.2365"></a>
<span class="sourceLineNo">2366</span>     * @param url the new value for the JDBC connection url<a name="line.2366"></a>
<span class="sourceLineNo">2367</span>     */<a name="line.2367"></a>
<span class="sourceLineNo">2368</span>    public synchronized void setUrl(final String url) {<a name="line.2368"></a>
<span class="sourceLineNo">2369</span>        this.url = url;<a name="line.2369"></a>
<span class="sourceLineNo">2370</span>    }<a name="line.2370"></a>
<span class="sourceLineNo">2371</span><a name="line.2371"></a>
<span class="sourceLineNo">2372</span>    /**<a name="line.2372"></a>
<span class="sourceLineNo">2373</span>     * &lt;p&gt;<a name="line.2373"></a>
<span class="sourceLineNo">2374</span>     * Sets the {@link #userName}.<a name="line.2374"></a>
<span class="sourceLineNo">2375</span>     * &lt;/p&gt;<a name="line.2375"></a>
<span class="sourceLineNo">2376</span>     * &lt;p&gt;<a name="line.2376"></a>
<span class="sourceLineNo">2377</span>     * Note: this method currently has no effect once the pool has been initialized. The pool is initialized the first<a name="line.2377"></a>
<span class="sourceLineNo">2378</span>     * time one of the following methods is invoked: &lt;code&gt;getConnection, setLogwriter,<a name="line.2378"></a>
<span class="sourceLineNo">2379</span>     * setLoginTimeout, getLoginTimeout, getLogWriter.&lt;/code&gt;<a name="line.2379"></a>
<span class="sourceLineNo">2380</span>     * &lt;/p&gt;<a name="line.2380"></a>
<span class="sourceLineNo">2381</span>     *<a name="line.2381"></a>
<span class="sourceLineNo">2382</span>     * @param userName the new value for the JDBC connection user name<a name="line.2382"></a>
<span class="sourceLineNo">2383</span>     */<a name="line.2383"></a>
<span class="sourceLineNo">2384</span>    public void setUsername(final String userName) {<a name="line.2384"></a>
<span class="sourceLineNo">2385</span>        this.userName = userName;<a name="line.2385"></a>
<span class="sourceLineNo">2386</span>    }<a name="line.2386"></a>
<span class="sourceLineNo">2387</span><a name="line.2387"></a>
<span class="sourceLineNo">2388</span>    /**<a name="line.2388"></a>
<span class="sourceLineNo">2389</span>     * &lt;p&gt;<a name="line.2389"></a>
<span class="sourceLineNo">2390</span>     * Sets the {@link #validationQuery}.<a name="line.2390"></a>
<span class="sourceLineNo">2391</span>     * &lt;/p&gt;<a name="line.2391"></a>
<span class="sourceLineNo">2392</span>     * &lt;p&gt;<a name="line.2392"></a>
<span class="sourceLineNo">2393</span>     * Note: this method currently has no effect once the pool has been initialized. The pool is initialized the first<a name="line.2393"></a>
<span class="sourceLineNo">2394</span>     * time one of the following methods is invoked: &lt;code&gt;getConnection, setLogwriter,<a name="line.2394"></a>
<span class="sourceLineNo">2395</span>     * setLoginTimeout, getLoginTimeout, getLogWriter.&lt;/code&gt;<a name="line.2395"></a>
<span class="sourceLineNo">2396</span>     * &lt;/p&gt;<a name="line.2396"></a>
<span class="sourceLineNo">2397</span>     *<a name="line.2397"></a>
<span class="sourceLineNo">2398</span>     * @param validationQuery the new value for the validation query<a name="line.2398"></a>
<span class="sourceLineNo">2399</span>     */<a name="line.2399"></a>
<span class="sourceLineNo">2400</span>    public void setValidationQuery(final String validationQuery) {<a name="line.2400"></a>
<span class="sourceLineNo">2401</span>        this.validationQuery = isEmpty(validationQuery) ? null : validationQuery;<a name="line.2401"></a>
<span class="sourceLineNo">2402</span>    }<a name="line.2402"></a>
<span class="sourceLineNo">2403</span><a name="line.2403"></a>
<span class="sourceLineNo">2404</span>    /**<a name="line.2404"></a>
<span class="sourceLineNo">2405</span>     * Sets the validation query timeout, the amount of time, in seconds, that connection validation will wait for a<a name="line.2405"></a>
<span class="sourceLineNo">2406</span>     * response from the database when executing a validation query. Use a value less than or equal to 0 for no timeout.<a name="line.2406"></a>
<span class="sourceLineNo">2407</span>     * &lt;p&gt;<a name="line.2407"></a>
<span class="sourceLineNo">2408</span>     * Note: this method currently has no effect once the pool has been initialized. The pool is initialized the first<a name="line.2408"></a>
<span class="sourceLineNo">2409</span>     * time one of the following methods is invoked: &lt;code&gt;getConnection, setLogwriter,<a name="line.2409"></a>
<span class="sourceLineNo">2410</span>     * setLoginTimeout, getLoginTimeout, getLogWriter.&lt;/code&gt;<a name="line.2410"></a>
<span class="sourceLineNo">2411</span>     * &lt;/p&gt;<a name="line.2411"></a>
<span class="sourceLineNo">2412</span>     *<a name="line.2412"></a>
<span class="sourceLineNo">2413</span>     * @param validationQueryTimeoutSeconds new validation query timeout value in seconds<a name="line.2413"></a>
<span class="sourceLineNo">2414</span>     */<a name="line.2414"></a>
<span class="sourceLineNo">2415</span>    public void setValidationQueryTimeout(final int validationQueryTimeoutSeconds) {<a name="line.2415"></a>
<span class="sourceLineNo">2416</span>        this.validationQueryTimeoutSeconds = validationQueryTimeoutSeconds;<a name="line.2416"></a>
<span class="sourceLineNo">2417</span>    }<a name="line.2417"></a>
<span class="sourceLineNo">2418</span><a name="line.2418"></a>
<span class="sourceLineNo">2419</span>    /**<a name="line.2419"></a>
<span class="sourceLineNo">2420</span>     * Starts the datasource.<a name="line.2420"></a>
<span class="sourceLineNo">2421</span>     * &lt;p&gt;<a name="line.2421"></a>
<span class="sourceLineNo">2422</span>     * It is not necessary to call this method before using a newly created BasicDataSource instance, but<a name="line.2422"></a>
<span class="sourceLineNo">2423</span>     * calling it in that context causes the datasource to be immediately initialized (instead of waiting for<a name="line.2423"></a>
<span class="sourceLineNo">2424</span>     * the first {@link #getConnection()} request). Its primary use is to restart and reinitialize a<a name="line.2424"></a>
<span class="sourceLineNo">2425</span>     * datasource that has been closed.<a name="line.2425"></a>
<span class="sourceLineNo">2426</span>     * &lt;p&gt;<a name="line.2426"></a>
<span class="sourceLineNo">2427</span>     * When this method is called after {@link #close()}, connections checked out by clients<a name="line.2427"></a>
<span class="sourceLineNo">2428</span>     * before the datasource was stopped do not count in {@link #getMaxTotal()} or {@link #getNumActive()}.<a name="line.2428"></a>
<span class="sourceLineNo">2429</span>     * For example, if there are 3 connections checked out by clients when {@link #close()} is invoked and they are<a name="line.2429"></a>
<span class="sourceLineNo">2430</span>     * not returned before {@link #start()} is invoked, after this method is called, {@link #getNumActive()} will<a name="line.2430"></a>
<span class="sourceLineNo">2431</span>     * return 0.  These connections will be physically closed when they are returned, but they will not count against<a name="line.2431"></a>
<span class="sourceLineNo">2432</span>     * the maximum allowed in the newly started datasource.<a name="line.2432"></a>
<span class="sourceLineNo">2433</span>     *<a name="line.2433"></a>
<span class="sourceLineNo">2434</span>     * @throws SQLException if an error occurs initializing the datasource<a name="line.2434"></a>
<span class="sourceLineNo">2435</span>     */<a name="line.2435"></a>
<span class="sourceLineNo">2436</span>    @Override<a name="line.2436"></a>
<span class="sourceLineNo">2437</span>    public synchronized void start() throws SQLException {<a name="line.2437"></a>
<span class="sourceLineNo">2438</span>        closed = false;<a name="line.2438"></a>
<span class="sourceLineNo">2439</span>        createDataSource();<a name="line.2439"></a>
<span class="sourceLineNo">2440</span>    }<a name="line.2440"></a>
<span class="sourceLineNo">2441</span><a name="line.2441"></a>
<span class="sourceLineNo">2442</span>    /**<a name="line.2442"></a>
<span class="sourceLineNo">2443</span>     * Starts the connection pool maintenance task, if configured.<a name="line.2443"></a>
<span class="sourceLineNo">2444</span>     */<a name="line.2444"></a>
<span class="sourceLineNo">2445</span>    protected void startPoolMaintenance() {<a name="line.2445"></a>
<span class="sourceLineNo">2446</span>        if (connectionPool != null &amp;&amp; timeBetweenEvictionRunsMillis &gt; 0) {<a name="line.2446"></a>
<span class="sourceLineNo">2447</span>            connectionPool.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);<a name="line.2447"></a>
<span class="sourceLineNo">2448</span>        }<a name="line.2448"></a>
<span class="sourceLineNo">2449</span>    }<a name="line.2449"></a>
<span class="sourceLineNo">2450</span><a name="line.2450"></a>
<span class="sourceLineNo">2451</span>    @Override<a name="line.2451"></a>
<span class="sourceLineNo">2452</span>    public &lt;T&gt; T unwrap(final Class&lt;T&gt; iface) throws SQLException {<a name="line.2452"></a>
<span class="sourceLineNo">2453</span>        if (isWrapperFor(iface)) {<a name="line.2453"></a>
<span class="sourceLineNo">2454</span>            return iface.cast(this);<a name="line.2454"></a>
<span class="sourceLineNo">2455</span>        }<a name="line.2455"></a>
<span class="sourceLineNo">2456</span>        throw new SQLException(this + " is not a wrapper for " + iface);<a name="line.2456"></a>
<span class="sourceLineNo">2457</span>    }<a name="line.2457"></a>
<span class="sourceLineNo">2458</span><a name="line.2458"></a>
<span class="sourceLineNo">2459</span>    private void updateJmxName(final GenericObjectPoolConfig&lt;?&gt; config) {<a name="line.2459"></a>
<span class="sourceLineNo">2460</span>        if (registeredJmxObjectName == null) {<a name="line.2460"></a>
<span class="sourceLineNo">2461</span>            return;<a name="line.2461"></a>
<span class="sourceLineNo">2462</span>        }<a name="line.2462"></a>
<span class="sourceLineNo">2463</span>        final StringBuilder base = new StringBuilder(registeredJmxObjectName.toString());<a name="line.2463"></a>
<span class="sourceLineNo">2464</span>        base.append(Constants.JMX_CONNECTION_POOL_BASE_EXT);<a name="line.2464"></a>
<span class="sourceLineNo">2465</span>        config.setJmxNameBase(base.toString());<a name="line.2465"></a>
<span class="sourceLineNo">2466</span>        config.setJmxNamePrefix(Constants.JMX_CONNECTION_POOL_PREFIX);<a name="line.2466"></a>
<span class="sourceLineNo">2467</span>    }<a name="line.2467"></a>
<span class="sourceLineNo">2468</span><a name="line.2468"></a>
<span class="sourceLineNo">2469</span>}<a name="line.2469"></a>




























































</pre>
</div>
</body>
</html>
